csv

Using Python csv module on updating file

I am using python's csv module to extract data from a csv that is constantly being updated by an external tool. I have run into a problem where when I reach the end of the file I get a StopIteration error, however, I would like the script to continue to loop waiting for more lines to be added by the external tool. What I came up with s...

Exporting japanese characters into csv from flex application exports garbled values

We have a flex application where we export the contents of table data into csv format. When we have japanese characters in our table the data exported contains junk character. We are using the fileReference class and the save method. According the documentation if the data to be saved is a String it is saved as a UTF-8 text file. Anybody...

Python halts while iteratively processing my 1GB csv file

I have two files: metadata.csv: contains an ID, followed by vendor name, a filename, etc hashes.csv: contains an ID, followed by a hash The ID is essentially a foreign key of sorts, relating file metadata to its hash. I wrote this script to quickly extract out all hashes associated with a particular vendor. It craps out before it fin...

ASP.NET CSV Response, Excel Exponential Format Issue

Hi, In my ASP.NET application, I need to write DataTable as CSV response to the customer. Everything is working fine except a column which has a numbers. Ex: 7002136138603600000 But when I open the CSV in Excel, it is showing in exponential format. Something like this: 7E+18 Could you please let me know what needs to be done in or...

Have writen a program to extract text from a PDF in python, and now need to make it run for every PDF in the folder and save as a text file.

So far here is the code I have (it is working and extracting text as it should.) import pyPdf def getPDFContent(path): content = "" # Load PDF into pyPDF pdf = pyPdf.PdfFileReader(file(path, "rb")) # Iterate pages for i in range(0, pdf.getNumPages()): # Extract text from page and add to content conte...

Python's CSV reader and iteration

I have a CSV file that looks like this: "Company, Inc.",,,,,,,,,,,,10/30/09 A/R Summary Aged Analysis Report,,,,,,,,,,,,10:35:01 All Clients,,,,,,,,,,,,USER Client Account,Customer Name,15-Jan,16 - 30,31 - 60,61 - 90,91 - 120,120 - Over,Total,Status,Credit Limit 1000001111,CLIENT A,0,0,"3,711.32",0,0,"18,629.64","22,340.96",COD,"20,000...

CSV files and multi line text cells

Hi, I am generating a simple csv file using php. The file contains some user's personal data. When I open the generated file in office, the addresses are not displayed in full height. I have to double click on the cell for the address to be shown fully (in full width and height) otherwise I can only see the first word/number of the addre...

Fastest way to import CSV files in MATLAB

I've written a script that saves its output to a CSV file for later reference, but the second script for importing the data takes an ungainly amount of time to read it back in. The data is in the following format: Item1,val1,val2,val3 Item2,val4,val5,val6,val7 Item3,val8,val9 where the headers are on the left-most column, and the da...

How do I export this Unicode table as CSV in Perl 5?

I have a table that has some Unicode in it. I know that the Unicode data is fine as it comes out as JSON on our webserver just fine. But for some reason the CSV that I'm generating is ending up mangled. Here's our current code: my $csv = Text::CSV->new ({ eol => "\015\012" }); open my $fh, '>:encoding(utf8)', 'Foo.csv'; my $sth...

What is a good CSV Java Utility

I was using opencsv which seemed fine but from the looks of the website it's gone so it's time to look for a new library to deal with parsing CSVs it is a simple task but I would like to keep it with a utility not have to roll my own or maintain one by myself. What is the best alternative? Seems like the opencsv site was updated and is ...

Importing CSV from a variable instead of file?

Hi Folks, I have a command that formats it's output in the form of CSV. I have a list of machine this command will run against using a foreach loop. in the below example $serverlist is automatically generated with an AD Query. foreach ($server in $serverlist) { $outputlist = mycommand } what I would like to do is somehow end up wit...

fgetcsv - Add Quotes to fields that do not have quotes

Hello all, I have a text file (its comma delimited with some fields wrapped around in double quotes) when I parse through it using this: if (($handle = fopen('C:\tester\fake.txt', "r")) !== FALSE) { while (($data = fgetcsv($handle, ",")) !== FALSE) { $num = count($data); //echo "<p> $num fields in line $row: <br /><...

SQL Server BCP: How to put quotes around all fields?

Hello all, I have this BCP command: 'bcp DBName..vieter out c:\test003.txt -c -T /t"\",\"" -S SERVER' The output CSV I get does not put quotes around the field names, instead it puts it around the commas! How can I get the /t"\",\"" to put quotes around all fields. Thanks all ...

Convert mysql query results to CSV (with copy/paste)

I often work in command line mysql. A common need is to take a query's results and import them into a Numbers document (similar to an Excel document). What is the fastest method for doing this? Method 1: Select into outfile You can select into an outfile directly from MySQL, but this takes several steps. export your query with all ...

Csv Calculation using java

Hi all, Thanks for reading my question. I have a CSV file, I read it and store it in a variable. Now i just want to PLUS all the column to see its sum. For example 3,34 12,673 23,8543 SUM ------------- 965,12658 Columns and rows can be N limit. Looks easy but don't know, its taking my all time. Please do let me know which data s...

Parsing CSV files in C#

Is there a default/official/recommended way to parse CSV files in C#? I don't want to roll my own parser. Also, I've seen instances of people using ODBC/OLE DB to read CSV via the Text driver, and a lot of people discourage this due to its "drawbacks." What are these drawbacks? Ideally, I'm looking for a way through which I can read th...

create a .csv file with values from a Python list

I am trying to create a .csv file with the values from a Python list when I print the values in the list they are all unicode (?) i.e. they look something like this [u'value 1', u'value 2', ...] if I iterate through the values in the list i.e. for v in mylist: print v they appear to be plain text and I can put a ',' between each with ...

Sorting CSV in Python

I assumed sorting a CSV file on multiple text/numeric fields using Python would be a problem that was already solved. But I can't find any example code anywhere, except for specific code focusing on sorting date fields. How would one go about sorting a relatively large CSV file (tens of thousand lines) on multiple fields, in order? Py...

Exporting .xls to .csv issues

I have been trying to import this excel file my mysql database, and it has been rough. There are around 7,000 rows in the .xls file, but when I export it to .csv and parse it with PHP I get one of two issues: Excel does not escape anything, ie. the commas in each row split the data When I change all commas to * then export for some rea...

TypeError upon merely opening a file with csv.DictReader?

I've just uploaded this CSV file via a form, POSTing it to my Python CGI script. The upload seems to have completed successfully. Permissions on the folder are 777, on the file are 755. >>> import csv >>> csvHandle = open('files/TestData.csv', "rb") >>> csvRawRecordDicts = csv.DictReader(csvHandle) Traceback (most recent call last): ...