Same problem
Hi all,
I am trying to accomplish the same thing, except the file isnt in CSV format.
Heres my case:
I have a 25mb file with 3000 employees record. Each record takes up exactly 5001 characters in the file, with information such as an employees name, address, phone number, salary, paycheck information etc. I get a file like that bi-weekly, which I need to import into an Oracle database through the ASP.NET app.
I will need to read the entire file, and from each 5001 characters to pick out the information I need, and call a Stored Procedure to save the infomration. The information will eventually be broken down into smaller chunks and stored into different tables (I have table for just personal information, another table for their tax information, a table for retirement plan information, a table for paycheck, etc.)
Right now Im doing the following:
1. Have an array to store the whole text file, with each block storing exactly 5001 characters, then
2. Use a Stringbuilder object to store one block of the array, then
3. Use smaller strings to save information I need from the stringbuilder, and
4. call Stored Procedures to save those information, and
5. go back to step 2 and repeat 3000 times.
This eats up a lot of RAM and sometimes even crashes my computer . I am sure the above method is a very stupid one...but Im a beginner programmer and this is the first time I work on an app with such intensive text-parsing.
Now I had to asks users to open the text file in Excel, save it as a spreadsheet, and have my application read it as a database so it reads one record at a time. This has caused inconvenience to them, and I really need an alternative solution to this...
The information in that text file isnt seperated by any symbols, so I am breaking it down solely by character position. Shall I still use bulk insert, put it into a temp table in Oracle, and break down the chunks from the database side?
And if I do break it down from the database, how can I tell (from the application) that the whole process is finished?
Thank you...