re: How to read CSV file using WO
re: How to read CSV file using WO
- Subject: re: How to read CSV file using WO
- From: Jason McInnes <email@hidden>
- Date: Wed, 29 Sep 2004 11:03:07 -0700 (PDT)
KB - I just figured out how to do this a few days ago. My WO app lets a user upload a text file with tab-delimited records in it and it batch loads the records in the file into the database. I'm having some memory issues (you might have seen my earlier post on that), but otherwise it's working pretty good.
The first thing I did was write the method that would accept a single delimited record, parse it using a StringTokenizer, validate its entries, and then turn it into an NSDictionary with the values.
Then I wrote class methods on EOs that would accept an input dictionary and an EOEditingContext and return EOs.
Then I switched gears and used the FileUpload example application that came with WO to teach myself how to upload a file and stream it to a directory in the file system. It's actually pretty straighforward.
After that, I added a file upload page to my WO app that would allow the file to be uploaded to a directory.
Then I checked out the WO example app for WOLongResponsePage. This is the page I have up and running while the batch loader is processing the file. This example was a little bit challenging to understand because of the multi-threading, but if you look at it long enough, you get an epiphany, at least, I did, about how it is working and then it was smooth sailing. It's the WOLongResponsePage that kicks off the BatchLoader in its performAction() method.
Then I wrote a Batch Loader class that would use a BufferedReader to open and read the input file one line at a time. It would then pass each line to the first method, the parser, and get back the dictionary. Then pass the dictionary to the appropriate EO Class to get back the EO in the editing context. then I'd save changes on the EditingContext and move on to the next line.
As for my memory problem, still researching, but if I use the Session's Default Editing Context, I don't have any memory problems and the batch loader runs quite well.
Hope that helps!
Jason
Date: Wed, 29 Sep 2004 10:58:28 +0800
From: Goh Keng Boon <
email@hidden>
Subject: How to read CSV file using WO
To: WebObjects (Group) <
email@hidden>
Message-ID: <
email@hidden>
Content-Type: text/plain; charset=US-ASCII; format=flowed
Hi guys, I'm intended to read a CSV file that located at my client's PC
using my webobject application, but i have no idea
where to star!
t, can i
have some pointers from you? A sample code or any
reference will be very appreciated.
Thank you very much.
KB
Jason McInnes
2 Degrees
Cell: 206.849.3680
Email: email@hidden
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden