csv

prevent CRLF in CSV export data

Hi, I have an export functionality that reads data from DB (entire records) and writes them in a .txt file, one record on a row each field being separated by ';'. the problem i am facing is that some fields contain CRLFs in it and when i write them to the file it goes to the next line thus destroying the structure of the file. The only...

How do I correctly handle CR when reading text files with OleDB

I have text files that are Tab delimited. I created a Schema.ini like so: [MY_FILE.TAB] Format=TabDelimited ColNameHeader=False Col1=id Short Col2=data Text This is the code I use to read it (C#): using (var connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\FolderToData\;Extended Properties='text;FMT=...

Why does csvwriter.writerow() put a comma after each character?

This code opens the url and appends the /names at the end and opens the page and prints the string to test1.csv: import urllib2 import re import csv url = ("http://www.example.com") bios = [u'/name1', u'/name2', u'/name3'] csvwriter = csv.writer(open("/test1.csv", "a")) for l in bios: OpenThisLink = url + l response = urllib2....

When and Why is XML preferable to CSV?

sometimes it feels like XML has been used just because it was fashionable. ...

Exporting to CSV - C#

Hello, I need to export a generic list to CSV. Obviously I could write my own, but would like to avoid this! I am able to google and find a lot of CSV parsers, but not many writers. I have downloaded FileHelpers but it doesn't properly escape output. For instance if a field is equal to ,,",,, the output is simply: ,,",,, For t...

Creating strongly typed DataTable from CSV file in byte[]

I am developing using C# 3 and .NET 3.5 and have an object where the contents of a CSV file (of an unknown format) are held in a byte[] property. I need to parse this byte[] and create a System.DataTable containing the columns and rows. The problem is creating a System.DataTable where column data types match the data in the CSV. I am c...

How can I organize each scraped item into a csv row?

What is the best way to organize scraped data into a csv? More specifically each item is in this form url "firstName middleInitial, lastName - level - word1 word2 word3, & wordN practice officeCity." JD, schoolName, date Example: http://www.examplefirm.com/jang "Joe E. Ang - partner - privatization mergers, media & technology...

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 for specific cases, but you have to understand well what encoding you are handling and use the appropiated snippet. Is there any universa...

Simple question, comma delimited id's to array in php 5.2

I've got a comma delimited string of id's coming in and I need some quick way to split them into an array. I know that I could hardcode it, but that's just gross and pointless. I know nothing about regex at all and I can't find a SIMPLE example anywhere on the internet, only huge tutorials trying to teach me how to master regular expres...

Convert XLS to CSV on command line

How could I convert an XLS file to a CSV file on the windows command line. The machine has Microsoft Office 2000 installed. I'm open to installing OpenOffice if it's not possible using Microsoft Office. ...

Can I use rrdtool with Perl to make graphs from CSV files?

Below is the sample data format in my CSV file. date,<options> YYYY-MM-DD,<values> Every next morning this CSV file has been updated with next date values. Can I use rrdtool to create graphs, and if so how? ...

Re-format items inside list read from CSV file in Python

I have some lines in a CSV file like this: 1000001234,Account Name,0,0,"3,711.32",0,0,"18,629.64","22,340.96",COD,"20,000.00",Some string,Some string 2 If you notice, some numbers are enclosed in " " and has a thousand separator ",". I want to remove the thousand separator and the double quote enclosure. For the qoute enclosure, I'm t...

how to import a csv or excel to pgAdmin III?

Hi people, How can you import to a table in PgAdmin III from an excel or CSV? Command copy works only when the file is in the server! :S ...

Load a CSV file into a DataGrid

I'm having a go at moving one of our simpler apps to Silverlight (a bit of a learning exercise). I've quickly come unstuck as I can't figure out how to load (or bind maybe?) a csv file to a datagrid (i.e. so you can point the app at a local csv file and display it to the user). I do have boilerplate code to parse a csv file and return a ...

Viewing CSV attachment in MFMailComposeViewController

Hello everyone, I have an application which generates a csv-file and then attaches it to an email using MFMailComposeViewController. This all works fine. My problem is that I would like to add an option to view the contents of the csv before sending it. This functionality exists in Mail, where an attached csv can be displayed as a spre...

Line break not happening in CSV file being generated by IE

I am using following PHP code to generate CSV file: header("Expires: 0"); header("Cache-control: private"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Description: File Transfer"); header("Content-Type: text/csv"); header("Content-disposition: atta...

Python to generate output ready for Excel

I have a Python script gathering info from some remote network devices. The output can be maybe 20 to 1000 lines of text. This then goes into excel on my local PC for now. Now access to this Linux device is convoluted, a citrix session to a remote windows server then ssh to the Linux device half way around the world. There is no ftp, sc...

convert from json to csv using python

i have a json file and i want to covert to .csv file but with python how to do this. sorry i new in using python 0 vote down check i have try import json import csv f = open('data.json') data = json.load(f) f.close() f = open('data.csv') csv_file = csv.writer(f) for item in data: f.writerow(item) f.close() but it no...

display preceeding zeros in csv file when viewing in excel

Is this at all possible? If I open up my file in standard text editor e.g. notepad the preceeding zeros are displayed. e.g. 000485001 shows up. Although this doesn't happen in excel. All that's displayed is 485001 Just wondering if there's a way around this? Thanks, ...

Command line CSV viewer?

Anyone know of a command-line CSV viewer for Linux/OS X? I'm thinking of something like less but that spaces out the columns in a more readable way. (I'd be fine with opening it with OpenOffice Calc or Excel, but that's way too overpowered for just looking at the data like I need to.) Having horizontal and vertical scrolling would be ...