XML Transformation.

Hello,

I'm trying to write a program that will take a CSV file, and convert it to XML, which I've seen code to do...however the program I'm trying to write needs to set the reading of each line to an interval (as scheduled at a fixed rate)...

Also I've seen many different tutorials and articles regarding how to transform CSV to XML and I'm a Java beginner so I don't really know which road to go down. I've already got some code to read a text file line by line but I don't really know where to go from there.

Any advise/pointers/help would be much appreciated.

[598 byte] By [CallMeRexa] at [2007-11-27 8:52:00]
# 1

Rex,

> I'm trying to write a program that will take a CSV file, and convert it to XML

Cool.

> needs to read each line to a fixed interval

Interesting, please elaborate... why the "fixed rate"? Are you tailing a transaction log file or something? Is the CSV being overwritten be some other process, and you want to check it for changes. Is the CSV file a dodgey request queuing mechanism.

There may be a much better/easier way.

> Also I've seen many different tutorials and articles regarding how to transform CSV to XML.

Research is good.

> I'm a Java beginner so I don't really know which road to go down.

Which roads are you considering?

> I've already got some code to read a text file line by line.

Cool.

> but I don't really know where to go from there.

Not so cool.

On the (scanty) information you've provided I'd suggest the you just need to read the file in an (interruptable) endless loop, with a sleep in it... google "sun java tutorials sleep".

The first listing just so happens to be an example of producer-consumer setup... if can modify the producer that would (I think, though I'm no OO guru) be an appropriate pattern.

Keith.

corlettka at 2007-7-12 21:06:36 > top of Java-index,Java Essentials,Java Programming...
# 2

>needs to read each line to a fixed interval

This is because the xml file is going to be fed to another system which needs to track the changes over time; the program is supposed to slowly 'grow' the xml file either as one file or as several versions/iterations.

The 'road' I have been crawling down makes use of dynamically storing the csv data in arrays and then writing according to definitions in a properties file.

CallMeRexa at 2007-7-12 21:06:36 > top of Java-index,Java Essentials,Java Programming...