csv

sort csv by column

Hi! I want to sort a CSV table by date. Started out being a simple task: import sys import csv reader = csv.reader(open("files.csv"), delimiter=";") for id, path, title, date, author, platform, type, port in reader: print date I used Python's CSV module to read in a file with that structure: id;file;description;date;author;pla...

determine the type of a value which is represented as string in python

When I read a comma seperated file or string with the csv parser in python all items are represented as a string. see example below. import csv a = "1,2,3,4,5" r = csv.reader([a]) for row in r: d = row d ['1', '2', '3', '4', '5'] type(d[0]) <type 'str'> I want to determine for each value if it is a string, float, integer or date....

fgetcsv and "0" value

Hey guys, So I'm using the PHP function fgetcsv to parse a .csv file (comma separated, fields are enclosed by "") and import it to a MySQL. The problem is, a certain field is always empty, even though it should sometimes contain "0". So I'm guessing the function consider "" and "0" as null values, but it's quite problematic for me. Any ...

How to export data from the database into .csv format programmatically?

I have stored some data in MySQL database through a java program. Now I want to export that data from the same program in .csv file. I know One method of doing this is to get all the fields of one row in variables and then store them in a file by seperating them with a comma(,) and by repeating the same for every row in the database. B...

Dynamically create a CSV file with FileHelpers

FileHelpers supports a feature called "RunTime Records" which lets you read a CSV file into a DataTable when you don't know the layout until runtime. Is it possible to use FileHelpers to create a CSV file at runtime in the same manner? Based on some user input, the CSV file that must be created will have different fields that can only ...

Export a VirtualStringTree to excel, csv ?

Is it possible to export a VirtualStringTree to Excel or CSV? I am using Delphi 2007 and trying to save my VirtualStringTree data records as Excel or CSV format. ...

How to load Excel or CSV file into Firebird?

I'm using Firebird database and I need to load Excel file into a database table. I need a tool that does this well. I tried some I found on Google, but all of them have some bugs. Since Excel data is not created by me, it would be good if it could scan the file and discover what kind of data is inside and suggest a table to be created ...

comparing csv files

I want to write a shell script to compare two .csv files. First one contains filename,path the second .csv file contains filename,paht,target. Now, I want to compare the two .csv files and output the target name where the file from the first .csv exists in the second .csv file. Ex. a.csv build.xml,/home/build/NUOP/project1 eesX.ja...

scanUpToCharactersFromSet stops after one loop

I'm trying to get the contents of a CSV file into an array. When I've done this before I had one record per line, and used the newline character with scanUpToCharactersFromSet:intoString:, passing newlineCharacterSet as the character set: while ([lineScanner scanUpToCharactersFromSet:[NSCharacterSet newlineCharacterSet] ...

Convert XML to CSV in PHP

Is there a way to convert an XML file to a CSV using PHP? ...

Convert large XML file to CSV in PHP

I have a 50MB XML file. I want to convert it to a CSV file, but most methods I have found exhaust the server memory. Is there a good way to do this using a stream method such as XMLreader. ...

Create a CSV file with PHP

I need to create a CSV file from a PHP array, I'm aware of the fputcsv() function. I've a recollection that a better function exists for this kind of stuff but I can't find it nor remember it's name. Does anyone know of such function or am I imagining? I might be making some confusion with the fgetcsv() function and the str_getcsv() ...

Importing bulk CSV data in UTF-8 into MySQL

Hi, I'm trying to import about 10K rows of UTF-8 encoded data into a new MySQL table. I can do so successfully with LOAD DATA INFILE via MySQL Workbench but it the UTF-8 characters get mangled. I've tested the database otherwise via PHP and it accepts stores UTF-8 charaters fine. The problem seems to be with LOAD DATA INFILE, and I've ...

JQuery: Get last td in tr within .each loop

Hi, I'm trying to loop through a table to create a csv string. I do some sorting through jquery on the table so I want to be able to get the resulting sorted data. Problem is I want to identify each new row, so add a \n or something after the last td of every row. The code below just isnt right. Any pointers appreciated. function GetCsv...

How to skip columns in CSV file when importing into MySQL table using LOAD DATA INFILE?

I've got a CSV file with 11 columns and I have a MySQL table with 9 columns. The CSV file looks like: col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 and the MySQL table looks like: col1, col2, col3, col4, col5, col6, col7, col8, col9 I need to map the columns 1-8 of CSV file directly to the first 8 columns of ...

Openoffice - CSV-export: is there a default escape-charcter?

Hello! As far as I can see OpenOffice, when it comes to save a file as a csv-file, encloses all strings in quote-characters. So is there any need for an escape character? and related to this question: Does OpenOffice have a default escape character? ...

How to read a CSV line with "?

A trivial CSV line could be spitted using string split function. But some lines could have ", e.g. "good,morning", 100, 300, "1998,5,3" thus directly using string split would not solve the problem. My solution is to first split out the line using , and then combining the strings with " at then begin or end of the string. What's th...

csv.reader turning commas into periods throwing errors

Here is a sample of the first row: link,Title,Description,Keywords It is made from an excel workbook, I tried saving in all CSV formats (window, ms-dos, and comma delimited list) I even tried saving in 2 txt file formats (window, ms-dos) k... here is the code: csvReader = csv.reader(file('files/my_file.csv', "rU"), delimiter=',') ...

Selecting before after character in regex

Basically I'm trying to get a bit of regex to do the following... I have some data I need to split, the sample data looks like this: Brand Name - Product Name Another Brand - Shoe Laces Heinz - Bakes Beans I want to be able to select the brand name or the product name but I can't seem to do it without catching the " - " part in the re...

Is it realistic to edit an ecommerce db with Excel?

Hi, I'm building an ecommerce website and the client insists that he'll be able to edit products with Excel spreadsheet. It is a bit complex ecommerce website. We have physical product - computer service - computer installation product with variations - shirt with different sizes group product - a shirt and a tie. Is it realistic ...