csv

How to get the contents of a field instead of `<bound method...` in a CSV output with Python (pytwist)

The snippet below is generating "weird" output: for s in servers: vo = ss.getServerVO(s) values = [] for f in voFields: attribValue = getattr(vo, f) values.append(attribValue) customValues = ss.getCustomFields(s) for f in customFields: values.append(customValues[f]) # Convert all values to...

Ignore newlines in CSV value

So I have a CSV that contains a filename and a file's contents. The file is full of newlines and all sorts of other characters. I need to have each row contain the filename in one column and the file contents in the next column, and then I need a new row, until the end of the file. The data looks like this: "filename.txt","hey there bu...

Export nested entities to CSV file

I have a rails app with some nested data that I'd like to export as a CSV file The models look like: class ContainerRecord < ActiveRecord::Base has_many :child_records and class ChildRecord < ActiveRecord::Base belongs_to :container_record I'd like to be able to export a CSV file with each ContainerRecord on a row with i...

Saving output of a query onto a text file in Ruby

I'm trying to query a table, fetch all records, and save the result as a CSV file. This is what I've done so far: require 'OCI8' conn = OCI8.new('scott','tiger','020') file = File.open('output.csv','w') do |f| conn.exec('select * from emp') do |e| f.write log.join(',') end end .. And while it does generate a CSV file, the proble...

CSV Parser in one routine/function?

I know there are several libraries of code out there that can parse CSV files according to the standard, but, for various reasons, I need one simple routine (not an entire library) that parses a CSV into a DataTable or array. Does such an animal exist or is it extinct? (Preferably C# but i can translate vb.net too) ...

Specifying Cell Format in CSV File

I am generating a csv file from a PHP array. It opens just fine in Excel and OpenOffice Calc, however the data in one of the column are zip codes. Excel makes the cell formats of the column number general by default. This results in the leading 0 getting dropped in zip codes. Is there any way I can specify the cell formats within the...

Is there a Ruby CSV parser that generates column getter methods?

Hi there, I'm trying to generalize a data retrieval mechanism with Ruby, and can't seem to find a way to retrieve a CSV file and access one of the row's columns by using a dot operator like so: Let's say I have a CSV table: #some_file.csv name,age albert,13 And I create a FasterCSV table from it: a = FasterCSV.new(File.open('some_fi...

CSV reading in java

Hello Im having trouble reading from a CSV file final String DELIMITER = ","; Scanner fileScan = null; Scanner dataSetScan = null; String dataSet = null; String sql = ""; File users = new File("user.txt"); String nickname = ""; String lastname = ""; String firstname = ""; String cartype = ""; Str...

Filling jTable in applet with CSV data. Will compile, will run, no data/table displayed.

I have been attempting to load CSV data into a java applet. I have been able to load the data into a java program but when I make the attempt to recreate this into a java applet, i am having difficulties. Here is the code I have that will run but display nothing: import java.io.*; import java.util.*; import javax.swing.*; import javax...

How to pre-process CSV data for FasterCSV?

We're having a significant number of problems creating a bulk upload function for our little app. We're using the FasterCSV gem to upload data to a MySQL database but he Faster CSV is so twitchy and precise in its requirements that it constantly breaks with malformed CSV errors and time out errors. The csv files are generally created b...

Creating csv files in ObjC

Hi All, Is it possible or any library available for creating .csv file in ObjC ? Thanks ...

How do I use awk to parse a fixed-width (NACHA) file format?

My company has a problem: we suspect that the NACHA files we are receiving from one of our application service providers that we use to draw money from our clients are incorrect. We have all of the ACH agreements and legal mumbo-jumbo in place, so it's not a problem with our use of the ACH network, and we're not receiving word from the...

How to remove new line (and some other) characters for csv output?

Hi I have some data (which users input using WYSIWYG editor). I have created a tool to create a csv copy of the data for some backup purposes. For each record I $csv_data .= str_replace( array('<br />','<br/>', '\n', ','), '', strip_tags($db_data['description']) ).","; for...

How to merge two csv files in php ?

I have two csv file. First File has date offerid clicks orders Second File has date offerid shown How can I merge this two csv file programmatically in php ? ...

Simple C# CSV Excel export class

Thought this might be handy for someone, this is an extremely simple CSV export class that I needed. Features: Extremely simple to use Escapes commas and quotes so excel handles them fine Exports date and datetimes in timezone-proof format Without further ado: using System; using System.Data.SqlTypes; using System.IO; using System.T...

PHP, CSV columns into separate arrays

Basically, i want to make a system where a user can upload a CSV file and pick what columns they want to upload/process I can do this fine by using fopen and foreach, but since the number of the column may vary from CSV to CSV.... i can store the picked columns in an array, eg picked[]= "1,2,4"; //from 1,2,3,4 columns comma separated...

Quotes in tab-delimited file

Hi all, I've got a simple application that opens a tab-delimited text file, and inserts that data into a database. I'm using this CSV reader to read the data: http://www.codeproject.com/KB/database/CsvReader.aspx And it is all working just fine! Now my client has added a new field to the end of the file, which is "ClaimDescription", ...

Load data from csv file (iphone SDk)

Does anyone know how to load data from csv file? For the code example, CPTestAppScatterPlotController.m that I downloaded from core-plot Google website, a line graph can be plotted based on randomly generated initial data x, y. // Add some initial data SMutableArray *contentArray = [NSMutableArray arrayWithCapacity:100]; NSUInteger ...

Comparing two CSV objects in Powershell

I want to compare two CSV files to see if they are different. I was thinking I could do that with Compare-Object, but that doesn't seem to work. $csvA = ConvertFrom-CSV "A,B,C`n1,1,1`n1,1,1" $csvB = ConvertFrom-CSV "A,B,C`n1,1,1`n1,1,2" Compare-Object $csvA $csvB There is no output on the last line. Why is that? ...

Why do multiline cells in my CSV file appear with a question mark at the end of each line in Excel?

I'm currently working on a project where we'd like to allow a user to export their data to CSV. Some of the data we present has multiple values for a single cell, and so we use the standard CSV method of putting each value on its own line: Column A, Column B, Column C Value A, "Value B1 Value B2", Value C Most of the time this works f...