csv

CSV File read. Special Chars problem.

Hi guys. I have to edit a csv file, the problem is that my special chars like ó ã ç gets screwed up. Heres is a peice of my code: static void ReadFromFile(){ StreamReader SR = new StreamReader("c:\\Users\\Levy\\Documents\\Vale\\Base\\Desknote.csv", Encoding.Default); StreamWriter SW = new StreamWriter("c:\\Users\\Levy...

PHP-based CSV editor?

Does anyone know of an online CSV editor written in PHP that will allow a user to open, edit, and save a given CSV file? All I can find are CSV classes and nothing that can handle dynamic files, just predefined lengths etc. ...

PHP Export MySQL to CSV - Results showing HTML

Hey everyone, I saw a post on this already, but it didn't really provide a solution (that has worked for me at least)... I have a PHP page that does some basic MySQL queries, the results of which are displayed on the page. I'm using some $_GET and $_SESSION variables throughout this process. In the same page, I also allow the user to ...

Column to row translation using sed

I'm writing a bash script to get data from procmail and produce an output CSV file. At the end, I need to translate from this: ---label1: 123456 ---label2: 654321 ---label3: 246810 ---label4: 135791 ---label5: 101010 to this: label1,label2,label3,label4,label5 123456,654321,246810,135791,101010 I could do this easily with a ruby s...

Whats the best way of putting tabular data into python?

I have a CSV file which I am processing and putting the processed data into a text file. The entire data that goes into the text file is one big table(comma separated instead of space). My problem is How do I remember the column into which a piece of data goes in the text file? For eg. Assume there is a column called 'col'. I just put s...

Python CSV DictReader/Writer issues

I'm trying to extract a bunch of lines from a CSV file and write them into another, but I'm having some problems. import csv f = open("my_csv_file.csv", "r") r = csv.DictReader(f, delimiter=',') fieldnames = r.fieldnames target = open("united.csv", 'w') w = csv.DictWriter(united, fieldnames=fieldnames) while True: try: row = r.ne...

How to search csv string and return a match by using a Javascript regex

I'm trying to extract the first user-right from semicolon separated string which matches a pattern. Users rights are stored in format: LAA;LA_1;LA_2;LE_3; String is empty if user does not have any rights. My best solution so far is to use the following regex in regex.replace statement: .*?;(LA_[^;]*)?.* (The question mark at th...

formatting fgetcsv output

Im trying to figure out how to take the data returned by fgetcsv, and format it into a readable/editable table, and then use fputcsv to save that table so far i have this <?php $row = 1; $handle = fopen("csv.csv", "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); $row++; for ($c=0; $c < $n...

Read CSV file into sqlite3 on the iPhone

Is there a way to read a CSV file into sqlite3 on the iPhone? Is there sqlite3 functionality similar to the SQL commands LOAD DATA LOCAL INFILE 'file.csv' INTO TABLE TABLENAME FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n'; Or is there an approach that converts the CSV file into a format that sqlite3 can read aut...

How can I merge fields in a CSV string using Python?

I am trying to merge three fields in each line of a CSV file using Python. This would be simple, except some of the fields are surrounded by double quotes and include commas. Here is an example: ,,Joe,Smith,New Haven,CT,"Moved from Portland, CT",,goo, Is there a simple algorithm that could merge fields 7-9 for each line in this format...

Elegant way to reverse column order

Hi, I have a file named ip-list with two columns: IP1 <TAB> Server1 IP2 <TAB> Server2 And I want to produce: Server1 <TAB> IP1 Server2 <TAB> IP2 What's the most elegant, shortest Linux command line tool to do it? ...

Problems importing a CSV file

When i try to import a CSV file into my mysql database I get this error "Invalid field count in CSV input on line 1". But i am sure that my csv file is fine. Below is the first line of the csv file and the structure of the databse: "","[email protected]","Licia Dallolio","390","37","","", CREATE TABLE `other_table` ( `id` int(11) N...

How can run an operation on one column of an CSV file in Perl?

Hi, I need to parse and convert an entire column in a simple CSV file that has two columns. John, 128222971326628000 Paul, 128491909317205000 Greg, 128160037933161000 Basically I need to perform some arithmetic on the second column and update the value in the column with the result of this operation while leaving the first column unt...

Using awk to "remove" unwanted text from CSV file

Hi, I have a CSV file like this: SUPPORT 07/30/2008-10:59:54 Eastern Daylight Time 123 07/03/2009-08:56:42 Eastern Daylight Time DC321 07/10/2009-20:16:56 Eastern Daylight Time where the date is an entire column. how can i remove the entire "Eastern Daylight Time" part of the string with awk? ...

MySQL - How to use subquery into IN statement by value

The question is to get table column data and use it as a value list for IN function; For this example I created 2 tables: movies and genres Table "movies" contains 3 columns: id, name and genre. Table "genres" contains 2 columns: id and name. +- movies-+ | |- movie_id - int(11) - AUTO_INCREMENT - PRIMARY | |- movie_nam...

Generating CSV file for Excel, how to have a newline inside a value

I need to generate a file for Excel, some of the values in this file contain multiple lines. there's also non-English text in there, so the file has to be Unicode. The file I'm generating now looks like this: (in UTF8, with non English text mixed in and with a lot of lines) Header1,Header2,Header3 Value1,Value2,"Value3 Line1 Value3 Li...

Having trouble using jquery and firebug

I'm trying to use the jquery csv plugin to load a csv file into an array. However, firebug is not very happy with it. Firebug keeps saying "not well-formed" when processing the csv file. The csv file looks like this: "PC0003","Windows XP Professional","2006/01/05" "PC0002","Windows XP Professional","2006/01/10" "PC0001","Windows XP Pr...

Emacs: import a CSV into org-mode

Emacs has a very nice extension by the name of org-mode. I would like to be able to easily load CSV files into org-mode without significant grief. All I've been able to find is table-import or table-capture, which, simply put, don't work even approximately well. Note that part of my issue is text strings with a comma within them. 1,2,...

How do i know how much space i need for mysql database

Let's say I'm importing multiple csv files into mysql. How can I find out how much space I need for this database (and as far as i noticed it doesn't seem to be the same size like csv files size)? ...

Programmatically extract data from an Excel spreadsheet.

Is there a simple way, using some common Unix scripting language (Perl/Python/Ruby) or command line utility, to convert an Excel Spreadsheet file to CSV? Specifically, this one: http://www.econ.yale.edu/~shiller/data/ie_data.xls And specifically the third sheet of that spreadsheet (the first two being charts). ...