ValueError: Can not convert string to float:

I am following a this tutorial to write a Naive Bayes Classifier: I keep getting this error: dataset[i] = [float(x) for x in dataset[i]] ValueError: could not convert string to

How can I combine CSV files and add header lines with python?

I have 50 csv files of price index data from St.Louis Fred, the format of each is like this: And I want to combine multiple csv files and add one more row of header to them to achieve the following format: So I can store the data in one csv file, may

Python CSV formatting with string and float and write

How do you format a float to 2 decimal points with mixed data type? I'm fetching a table and writing rows to csv file. My data is (string, string, float, float, float...) sql = 'select * from testTable' c.execute(sql) columnNames = list(map(lambda x:

Reading a CSV file and writing to a CSV file

use Text::CSV; $csv = Text::CSV->new; open(HIGH, "+>Hardtest.csv") || die "Cannot open ticket $!\n"; #reads the high file while(<HIGH>) { print "Printing High Priority Tickets ...\n"; sleep(1); print <HIGH>;

Notepad ++ How to add a comma to a specific column position?

I have pretty large ASCII file (1.7mil rows) that I need to insert commas into at specific column positions. I am doing this because I am trying to convert the file to csv so I can import it into mysql. Unless there is a better approach (no doubt), w

Reading a csv file with a timestamp column, with pandas

When doing: import pandas x = pandas.read_csv('data.csv', parse_dates=True, index_col='DateTime', names=['DateTime', 'X'], header=None, sep=';') with this data.csv file: 1449054136.83;15.31 1449054137.43;16.19 1449054138.04;19.22 1449054138.65;15.12

Python CSV delete empty lines

This question already has an answer here: CSV file written with Python has blank lines between each row 5 answers Im having a hard time trying to delete empty(blank) rows from a csv file using python 3.4.3. Each time I run my script the output remain

Comparing two CSV files and exporting non-matches using Python

As a beginner in using Python I'm stuck yet again! I've got two CSV files as follows: CSV1 (Master List) ID Name Code. Prop 12 SAB 1234 ZXC 12 SAB 1236 ZXC 12 SAB 1233 ZXC 12 SAB 1234 ZXC 11 ASN 1234 ABV 16 HGF 1233 AAA 19 MAB 8765 BCT 19 MAB 8754 BC

Read the csv file in R

I am trying to read a .csv file in R. My file looks like this- A,B,C,D,E 1,2,3,4,5 6,7,8,9,10 . . . number of rows. All are strings. First line is the header. I am trying to read the file using- mydata=read.csv("devices.csv",sep=",",he

Read the chosen CSV line

I have a really big CSV file with about 1,000,000 rows and it takes about 500 MB of memory. I don't have to read all the file. I want read every one hundredth line from the file. I try to do it by ReadLines, but it is really slow, faster is ReadAllLi

Replace multiple consecutive whitespace with 1 comma in unix

I have the following sed command: sed 's/\s/,/g' input > output.csv (I got the command from this related topic) which turns the following input: SNP A1 A2 FRQ INFO OR SE P 10:33367054 C T 0.9275 0.9434 1.1685 0.1281 0.1843 10:33367707 G A 0.9476 0.94

inserting column headers in the hsqldb text file

I'm modifying someone else's Java code, learning Java as I go. :-). I'm writing hsqldb TEXT files, and I would like the final files to have a 'heading' row, so that they can be more easily understood as plain text. hsqldb has a switch 'ignore_first=t

ServiceStack - dictionary for csv

In my project I use ServiceStack to allow user to export data in csv format. It's ServiceStack that makes the job but it always sorts my dictionary by alphabetical and I don't want that. I want that my csv file have his columns in exact order that I

Updated vba code and again it gives me a clue off beach error

This question already has an answer here: Subscript out of range error in this excel vba script [duplicate] 2 answers This code still gives me an out of subscript error Sub importData2() ChDir "C:\Users\Desktop\Java" Dim filenum(0 To 10) As Long

Python creates a function to write an object quickly

Hi I'm trying to write a small helper function to save an object to a csv under its own name. I'm working with arrays of data and this is intended to be a workaround to help visualise the array easily to help with editing it. The challenge I'm facing

Best way to handle long integers in a CSV file

I have a csv file with a column where the integers are over 16 characters long. The issue with this is that it changes the integer to a short abbreviation example: 8.71688E+17, is there a way in c# you can convert it back to a long integer without ha

Exporting CSV opens Office correctly (save numbers under TEXT)

I am using OPEN-OFFICE to work and save CSV. I am using the comma delimiter and ' " ' also. However, when saving the CSV, all numbers are not encapasulated. How can I force Open-Office to treat numbers as a Text and have them encapsulated too. Exampl

Writing a list of strings in an Excel CSV file in Python

I am trying to create a csv file that contains the contents of a list of strings in Python, using the script below. However when I check my output file, it turns out that every character is delimited by a comma. How can I instruct the CSV.writer to d

Build a flat table from CSV files

I have 500 CSV files in this format: IndicatorA_Name.csv 1900 1901 1902 ... Norway 3 2 Sweden 1 3 3 Denmark 5 2 3 ... IndicatorB_Name.csv 1900 1901 1902 ... Norway 1 3 4 Sweden 1 2 Iceland 1 6 3 ... Years in columns, countries in rows. Notice that co

Get csv and compare the lines. ArrayList? Java

i dont't use java very often and now i got some Problem. I want to read a CSV file like this one: A,B,C,D A,B,F,K E,F,S,A A,B,C,S A,C,C,S Java don't know dynamic arrays, so i choose an ArrayList. This works so far. The Problem is: How can I store the

Simplified CSV to SQL javascript file converter

Is there simpler way to convert CSV files to SQL file than this?: BufferedReader input = new BufferedReader(new FileReader(new File("c:\\file.csv"))); Writer output = new BufferedWriter(new FileWriter(new File("c:\\file.sql"))); try {

Importing CSV files into .Net

I realize this is a newbie question, but I'm looking for a simple solution - it seems like there should be one. What's the best way to import a CSV file into a strongly-typed data structure? Again simple = better.Check out FileHelpers Open Source Lib