Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Convert Csv To Xml, The following options are supported
titoo
post Mar 29 2008, 10:10 PM
Post #1


Newbie [ Level 1 ]
*

Group: Validating
Posts: 5
Joined: 29-March 08
Member No.: 29,477



QUOTE
The following options are supported in the DataDirect XML Converter CSV converter precisely because they are unspecified in the real world, and vary between applications.

Whether the first row of the CSV data contains the names of the fields, or they are known by the sending and receiving applications implicitly
How commas within values are handled in CSV files
How quotes within quoted values are handled in CSV files. Are they doubled to escape them, or is there a special escape character, such as a backslash?
Whether single or double quotes are used
Whether runs of consecutive but empty fields should be ignored
What encoding is used — Windows1252, ISO-8859-1 or US-ASCII are the most common
What line ending is used — CR/LF from Windows, LF from Unix/Linux, or CR from the Macintosh are often seen
TSV Files
A close cousin to CSV files are TSV, or Tab Separated Value files. These are a common export format from spreadsheets also. There is a separate DataDirect XML Converter for these, but it actually is just the CSV Converter in disguise, since either can be converted to the other by changing the definition of the separator character from comma to tab.

CSV Sample File
Use the following sample CSV file for use in trying out DataDirect XML Converters:

Title,Author,ISBN13,Pages
1984,George Orwell,978-0451524935,268
Animal Farm,George Orwell,978-0451526342,144
Brave New World,Aldous Huxley,978-0060929879,288
Fahrenheit 451,Ray Bradbury,978-0345342966,208
Jane Eyre,Charlotte Brontė,978-0142437209,532
Wuthering Heights,Emily Brontė,978-0141439556,416
Agnes Grey,Anne Brontė,978-1593083236,256
Walden,Henry David Thoreau,978-1420922615,156
Walden Two,B. F. Skinner,978-0872207783,301
"Eats, Shoots & Leaves",Lynne Truss,978-1592400874,209

CSV File Reading and Writing
Using the above file, a tiny Java, C# or VB.Net program can quickly transform the input CSV to XML, or convert XML to CSV. For example, the following Java program converts the above CSV sample file into XML and writes the output to the console.

import java.io.*;
import javax.xml.transform.stream.*;
import com.ddtek.xmlconverter.*;
public class CSVDemo {
public static void main(String[]args) throws Throwable {
ConverterFactory factory = new ConverterFactory();
ConvertToXML toXML = factory.newConvertToXML("converter:CSV:first=yes");
OutputStreamWriter w = new OutputStreamWriter(System.out, "US-ASCII");
toXML.convert(new StreamSource(args[0]), new StreamResult(w));
}
}

This would create the following output (with some parts removed).

<?xml version="1.0" encoding="US-ASCII"?>
<table>
<row>
<Title>1984</Title>
<Author>George Orwell</Author>
<ISBN13>978-0451524935</ISBN13>
<Pages>268</Pages>
</row>
...
<row>
<Title>Jane Eyre</Title>
<Author>Charlotte Brontė</Author>
<ISBN13>978-0142437209</ISBN13>
<Pages>532</Pages>
</row>
...
<row>
<Title>Eats, Shoots & Leaves</Title>
<Author>Lynne Truss</Author>
<ISBN13>978-1592400874</ISBN13>
<Pages>209</Pages>
</row>
</table>

XML to CSV

Going from XML to CSV is just as important, and the code is just as small. It takes no special schema, and it doesn't even take XQuery or XSLT. Anything immediately under the root element becomes the rows, and anything under that becomes the values between the commas. In the above example, switching to the ConvertFromXML class and writing the sample XML in would produce the initial CSV file.

Just like the EDI converters and other converters in the DataDirect XML Converters suite, CSV (and TSV) converters are fully bidirectional.

How To Use CSV Files
CSV files often are used as a bridge between older applications and newer ones. Having a tool that transparently reads and writes CSV format files in your toolbox can be very valuable. So whether you have to merge inventory data coming from an outside vendor into your database or publish a list of financial figures for your accountants, being able to bridge these two worlds is the purpose of the DataDirect XML Converters. You can get started with directly accessing CSV data from your Java or .NET applications by downloading a free trial of DataDirect XML Converters today.
Go to the top of the page
 
+Quote Post
yordan
post Mar 30 2008, 01:04 PM
Post #2


Way Out Of Control - You need a life :)
Group Icon

Group: [MODERATOR]
Posts: 1,957
Joined: 16-August 05
Member No.: 7,896



Hi, titoo.
Please have a more careful look at our forum rules.
One of these rule is usually named politeness, or scientifical honesty, or intellectual property respect.
Please feel free repeating what somebody else said.
But each sentence you did not write by yourself, you should mention the person who really said it, and put it between qutoes.
For instance, when repeating what I just said, you should write don the following way.
As Yordan said,
QUOTE
please be polite and honest

For instance, your post is very interesting, I am glad to be informed about that. But you should have mentionned that it is coming from the site http://www.xmlconverters.com/csv/#
Today I inserted the quotes for you in your post. Next time please use the "quote" button in order to insert the quotes by yourself. Else we could imagine that you are trying to cheat with our credit system, and this makes the admin's around here very angry. mad.gif
Regards
Yordan
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Converting Flash Files To Gif(6)
  2. Convert Currency Using Google(0)
  3. How To Remove Internet Options Features(7)
  4. Trap17.net : Ad Supported Free Web Hosting!(11)
  5. Mac <-> Pc <-> Opentype Font Conversion Utilities(0)
  6. Convert Fat32 To Ntfs Without Data Loss (dos-mode)(4)
  7. Does Anyone Know How To Convert .nsv Format?(1)
  8. Is Lasso Supported At Astahost ?(2)
  9. Forum Admins: Convert Other Boards To phpBB Easily(5)
  10. HTTPS - Supported Or Not?(11)
  11. Help: $_post Variable For Options From Select Types?(6)
  12. Itunes And Your MP3 Player(2)
  13. Update Your Nec Dvd Burner Fireware To Get Dvd-ram Supported(0)
  14. How: Disable A Few Options In WinXP Limited A/c ?(7)
  15. Automatic Options(1)
  1. Would My Modem Be Supported ?(6)
  2. What Database Do You Use With PHP(5)
  3. Rm Avi To Divx Avi ? How ?(7)
  4. Program To Convert M4p To M4a In Batches Quickly(3)
  5. How To Start A Program On Startup With Options(11)
  6. VGA Mode Not Supported Message On Monitor(9)
  7. How To Convert A Kick Into A Goal?(2)
  8. Convert Video, Music, Images, Pdf And More(2)
  9. Dir2html 1.1.0(4)
  10. Convert To Ipod(0)
  11. Share : How To Rip Dvd And Convert Video To Ipod Or Iphone Or Zune(1)
  12. Guide For Beginner Convert Video To Psp(2)
  13. Do I Need To Set Up Any Special Kernel Options To Enable Cd/dvd Burning?(0)


 



- Lo-Fi Version Time is now: 7th August 2008 - 11:30 PM