csv

Importing csv files using groovy

Hi! I have developed a groovy application. Now it has been required that for feeding the DB a CSV interface must be provided. That is, I have to load a csv file, parse it and insert records into the DB in a transactional way. The question is if there exists for groovy something like ostermiller utils (a configurable csv parser). Than...

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 Lawyer(models.Model): firm_url = models.URLField('Bio', max_length=200) firm_name = models.CharField('Firm', max_length=100) first = mode...

CSV to JSON script

I took this script from here: import csv from itertools import izip f = open( '/django/sw2/wkw2/csvtest1.csv', 'r' ) reader = csv.reader( f ) keys = ( "firm_url", "firm_name", "first", "last", "school", "year_graduated" ) out = [] for property in reader: property = iter( property ) data = {} for key in keys: data[ key ...

Groovy csv parser and export to database

How can I parse my CSV file without parsing first line ? This class work but I don't want to parse the header of my CSV. import groovy.sql.Sql class CSVParserService { boolean transactional = false def sql = Sql.newInstance("jdbc:mysql://localhost/RProject", "xxx", "xxx", "com.mysql.jdbc.Driver") def CSVList = sql.dataS...

How to populate sqlite3 in django?

My plan is to collect data from websites in batches (lawyer bios from each firm's website; since they are all different, I will use a modified spider for each site) and convert each batch into a csv file; then to json; and then load it to database. So I will need to append each new file to the existing database. Please let me know how to...

Is it possible to keep the column order using the Python csv DictReader

For example, my csv has columns as below: ID, ID2, Date, Job No, Code I need to write the columns back in the same order. The dict jumbles the order immediately, so I believe it's more of a problem with the reader. ...

csv2json.py error

I am trying to run the script csv2json.py in the Command Prompt, but I get this error: C:\Users\A\Documents\PROJECTS\Django\sw2>csv2json.py csvtest1.csv wkw1.Lawyer Converting C:\Users\A\Documents\PROJECTS\Django\sw2csvtest1.csv from CSV to JSON as C:\Users\A\Documents\PROJECTS\Django\sw2csvtest1.csv.json Traceback (most recent call la...

Django loaddata ValidationError

This thread got too confusing (for me) so I am asking the question again. I could not make the csv2json.py script mentioned in the original question work. I am just trying to find a way to import data to sqlite3 database. Here's the model I am working with: from django.db import models class School(models.Model): school = mode...

Parsing a comma-delimited std::string

If I have a std::string containing a comma-separated list of numbers, what's the simplest way to parse out the numbers and put them in an integer array? I don't want to generalise this out into parsing anything else. Just a simple string of comma separated integer numbers such as "1,1,1,1,2,1,1,1,0". ...

Read a csv data file and reutrn one specific StudentID marks for all their modules in Java

Hi, at the moment I have this: import java.util.*; import java.io.*; import java.io.BufferedReader; import java.io.FileReader; public class StudentID { public static void main(String[] args)throws Exception{ System.out.println ("Please enter StudentID: "); BufferedReader reader = new BufferedReader (new FileReader("CW2_data.c...

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 or worker1.age anytime i want. class ageName(object): '''class to represent a person''' def __init__(self, name, age): self.name = name sel...

What character set is this?

I received a bunch of CSV files from a client (that appear to be a database dump), and many of the columns have weird characters like this: Alain Lefèvre Angèle Dubeau & La Pietà That's seems like an awful lot of characters to represent an é. Does anyone know what encoding would produce that many characters for ...

Excel changes date formats

I run a process to produce a rather large CSV file of data. Sometimes I find it helpful to open the CSV in excel, make changes manually, and then re-save. However, if there are dates in the CSV, excel automatically reformats them. Is there a way to prevent excel from doing this? It would be helpful if I could turn off all text format...

convert from a 2d array to nested_set in Ruby on rails

I have a tree structure in a .csv file (nodes are of type text), and after reading the csv i want to store the data in a ruby object. I went through a few tree plugins and i think nested_set would serve the purpose for me. However, i am facing problem with fixing a format of csv file, so that i can read it and convert into tree object. I...

Please help, my program is not accepting MySQL floats

I have to use a java program . I need to understand it and then modify it. The program has a source folder. It has a lot of java files. the program has a GUI interface. i have imported the program in eclipse and i can run the program. i want to learn and understand the code but since its too big i want to only read the relevant portions ...

csv utf-8 writer - compability with python2.4

At the bottom of this manual http://docs.python.org/library/csv.html we have example of UnicodeWriter But how can i use this example in python 2.4 I got exception about codecs.getincrementalencoder(encoding)(). Property getincrementalencoder created only in version 2.5. Who can replace this property? Thanks! ...

How to import multiline csv files?

I got a file in this format. "abc";"def";"ghi asdasd asdasd asd asd aas d " Now i want to import it with Java. Does anyone know a library that support this kind of import? ...

Pilcrow appears in all the column values after importing from CSV file - MYsql

Hello All, my CSV content looks like this 1234,123;123;123 5675,123;567;234;565 No Space is provided at the end of each row in CSV i.e. 1234,123;123;123(No space here) Imported this using the following command mysql> load data local infile 'E:\sample.csv' into table Test.Table1 fields terminated by ',' lines terminated by '\n' (Co...

How to parse file in php and generate insert statements for mysql?

In case of csv file we have fgetcsv in php to parse and get the output but in my case file is .dat and I need to parse it and store it into MySQL Database and so do we have any built in function in php like fgetcsv that can work in similar fashion on .dat file ? Here is the sample value, it has headers DF_PARTY_ID;DF_PARTY_CODE;DF_CONNE...

django download csv file using a link

I am a new to django and python. Need some guidance in this quest. Case: When the user hits the submit button on a form, it should display Success page and a link where they can download the results. The results are in excel file. I can create output to excel file using xlwt module and display the success page individually but not both ...