7
votes
4answers
3k views

Python out of memory on large CSV file (numpy)

I have a 3GB CSV file that I try to read with python, I need the median column wise. from numpy import * def data(): return genfromtxt('All.csv',delimiter=',') data = data() # This is where it ...
11
votes
2answers
5k views

Python's CSV writer produces wrong line terminator

According to the its documentation csv.writer should use '\r\n' as lineterminator by default. import csv with open("test.csv", "w") as f: writer = csv.writer(f) rows = [(0,1,2,3,4), ...
28
votes
7answers
9k views

Python csv library with Unicode/UTF-8 support that “just works”

The csv module in Python doesn't work properly when there's UTF-8/Unicode involved. I have found in Python documentation (http://docs.python.org/library/csv.html) and other webpages snippets that work ...
20
votes
5answers
15k views

Reading a UTF8 CSV file with Python

I am trying to read a CSV file with accented characters with Python (only French and/or Spanish characters). Based on the Python 2.5 documentation for the csvreader ...
11
votes
7answers
17k views

convert from json to csv using python

I have a JSON file that I want to covert to a CSV file. How can I do this via Python? 0 vote down check I tried: import json import csv f = open('data.json') data = json.load(f) f.close() f = ...
22
votes
8answers
11k views

Python CSV error: line contains NULL byte

I'm working with some CSV files, with the following code: reader = csv.reader(open(filepath, "rU")) try: for row in reader: print 'Row read successfully!', row except csv.Error, e: ...
5
votes
4answers
2k views

Convert .csv file into .dbf using Python?

How can I convert a .csv file into .dbf file using a python script? I found this piece of code online but I'm not certain how reliable it is. Are there any modules out there that have this ...
0
votes
3answers
5k views

Python: Comparing two CSV files and searching for similar items

So I've got two CSV files that I'm trying to compare and get the results of the similar items. The first file, hosts.csv is shown below: Path Filename Size Signature C:\ a.txt 14kb ...
27
votes
3answers
20k views

writing header in csv python with DictWriter

assume I have a csv.DictReader object and I want to write it out as a csv file. How can I do this? I thought of the following: dr = csv.DictReader(open(f), delimiter='\t') # process my dr object # ...
8
votes
2answers
2k views

Appending items to a list of lists in python

I'm getting mad with list indexes, and i cannot explain what i'm doing wrong. I have this piece of code, in which i want to create a list of lists, each one containing values of the same circuit ...
4
votes
3answers
11k views

python csv into dictionary

I am pretty new to python. I need to create a class that loads csv data into a dictionary. I want to be able to control the keys and value So let say the following code, I can pull out worker1.name ...
7
votes
4answers
4k views

Python3: writing csv files

I'm trying to use Python 3.2 on a Windows computer to write a simple CSV file, however I'm having no luck. From the csv module documentation for Python 3.2: >>> import csv >>> ...
2
votes
4answers
2k views

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. ...
0
votes
4answers
5k views

reading csv files in scipy/numpy in Python

I am having trouble reading a csv file, delimited by tabs, in python. I use the following function: def csv2array(filename, skiprows=0, delimiter='\t', raw_header=False, missing=None, ...
12
votes
3answers
5k views

python : getting rid of extra line:

import csv with open('thefile.csv', 'rb') as f: data = list(csv.reader(f)) import collections counter = collections.defaultdict(int) for row in data: counter[row[10]] += 1 with ...
6
votes
2answers
2k views

Python csv: UnicodeDecodeError

I'm reading in a file with Python's csv module, and have Yet Another Encoding Question (sorry, there are so many on here). In the CSV file, there are £ signs. After reading the row in and printing ...
5
votes
4answers
4k views

python: creating excel workbook and dumping csv files as worksheets

I have few csv files which I would like to dump as new worksheets in a excel workbook(xls/xlsx). How do I achieve this? Googled and found 'pyXLwriter' but it seems the project was stopped. While Im ...
3
votes
5answers
2k views

Using Python to analyze CSV data, how do I ignore the first line of data

I am asking python to print the minimum number from a column of CSV data, but the top row is the column number, and I don't want Python to take the top row into account. How can I make sure Python ...
5
votes
6answers
4k views

How do I create a CSV file from database in Python?

I have a Sqlite 3 and/or MySQL table named "clients".. Using python 2.6, How do I create a csv file named Clients100914.csv with headers? excel dialect... The Sql execute: select * only gives table ...
7
votes
2answers
11k views

Python CSV file writing

I need to write into a csv file using python and each iterator item should start in a new line. So delimiter I am using is "\n". After each list has been written,next list should write from next cell. ...
4
votes
4answers
1k views

Generate table schema inspecting Excel(CSV) and import data

How would I go around creating a MYSQL table schema inspecting an Excel(or CSV) file. Are there any ready Python libraries for the task? Column headers would be sanitized to column names. Datatype ...
2
votes
2answers
747 views

CSV Rows to XML files using Python

I have csv file that looks like this: artist,year,id,video_name,new_video_id,file_root_name,video_type ,,,,,, Clay Aiken,1,clay_aiken,Sorry Seems To Be...,sorry-seems-to-be,02_sc_ca_sorry,FLV Clay ...
0
votes
0answers
202 views

Downloading/exporting a csv file when clicked on a button in web.py python

I am using python web.py framework to build a small web app. It consists of a Home page that takes a url as input Reads anchor text and anchor tags from it Writes it to csv file and downloads it ...
0
votes
3answers
260 views

Creating a dictionary from a CSV file

I am in the process of trying to write a python script that will take input from a CSV file and then push it into a dictionary format (I am using Python 3.x). I use the code below to read in the CSV ...
0
votes
1answer
1k views

How do I transfer data in .csv file into my sqlite database in django?

This is my models.py from django.db import models class School(models.Model): school = models.CharField(max_length=300) def __unicode__(self): return self.school class ...
7
votes
2answers
3k views

CSVWriter not saving data to file - WHY?

Python newbie getting a bit frustrated with the csv module. At this rate, it would have been easier if I wrote the file parser myself, but I want to do things the Pythonic way .... I have written a ...
5
votes
5answers
915 views

python csv reader behavior with None and empty string

I'd like to distinguishing None and empty strings when going back and forth between python data structure and csv representation using python's csv module. My issue is that when I run import csv, ...
2
votes
2answers
1k views

Python: How to write a dictionary of tuple values to a csv file?

How do I print the following dictionary into a csv file? maxDict = {'test1': ('alpha', 2), 'test2': ('gamma', 2)} So, that the output CSV looks as follows: test1, alpha, 2 test2, gamma, 2
1
vote
2answers
253 views

Filtering a CSV file in python

I have downloaded this csv file, which creates a spreadsheet of gene information. What is important is that in the HLA-* columns, there is gene information. If the gene is too low of a resolution e.g. ...
1
vote
2answers
1k views

How to Filter from CSV file using Python Script

I have abx.csv file having three columns. I would like to filter the data which is having Application as Central and write it in same .csv file User ID Name Application 001 Ajohns ...

1 2 3 4 5
15 30 50 per page