Re: Load a string of CSV from memory into a dataset
- From: "andrei" <andrei.toma@xxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 26 May 2005 08:41:13 -0400
Hi Sahil, and thank you for the reply.
Unfortunately, I can't do a split on each line using "," as a separator - I
have a field (a description) which could contain commas inside, so that
would create more fields than normal :(
ex: "2,4-DINITROPHENOL" or "DICYCLOHEXYLMETHANE-4,4'-DIISOCYANATE"
I was thinking of splitting by <","> that is using the three characters as
delimiter, but there are numerical values which are not surrounded by double
quotes, like : 33.4, 2,0,0,1, 2.5
So this doesn't work either...
Other ideas ?
Thanks,
Andrei.
"Sahil Malik [MVP]" <contactmethrumyblog@xxxxxxxxxx> wrote in message
news:e$H9pbXYFHA.3032@xxxxxxxxxxxxxxxxxxxxxxx
> Yes there is. As a matter of fact, you should avoid writing to the disk as
> that is hella slow.
>
> What you can do however is that the "Stream" you get - (is it
> MemoryStream?) - which after decryption and just before writing to the CSV
> file - subject that to a "StreamReader" - to get a string out of it.
>
> Great, now that you have a CSV'ed string out of it, split the string for
New
> lines.
> Then run a foreach on the resulting array and split each line (array
> element) using the "," character.
> For each sub array element - create an object array - and do a
> DataTable.LoadDataRow(passinthearray,true).
>
> Thats it. Problem solved.
>
> - Sahil Malik [MVP]
> http://codebetter.com/blogs/sahil.malik/
>
>
>
> "andrei" <andrei.toma@xxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:#PDYoXWYFHA.3356@xxxxxxxxxxxxxxxxxxxxxxx
> > Hi Group,
> >
> > Here is what I'm trying to do in my application:
> > 1. the customer uploads an encrypted file to the server (it's a ASP.NET
> > application)
> > 2. the uploaded file is decrypted to a comma separated list of values
> > 3. the list is being written to a CSV file
> > 4. the csv file is being loaded into a datatable, using OleDbDataAdapter
> > 5. the recordset, after some checking and validation, is being written
to
> a
> > SQL database.
> >
> > Question:
> >
> > Is it possible to skip somehow the steps where I'm writing the comma
> > separated list to a csv file and then reloading the list into a
datatable?
> > Something like loading the datatable directly from the comma separated
> > string **in memory** ?
> >
> > Many thanks !
> >
> > Andrei.
> >
> >
>
>
.
- Follow-Ups:
- Re: Load a string of CSV from memory into a dataset
- From: Sahil Malik [MVP]
- Re: Load a string of CSV from memory into a dataset
- From: Adrian Moore
- Re: Load a string of CSV from memory into a dataset
- References:
- Load a string of CSV from memory into a dataset
- From: andrei
- Re: Load a string of CSV from memory into a dataset
- From: Sahil Malik [MVP]
- Load a string of CSV from memory into a dataset
- Prev by Date: Re: Join on two data tables in same dataset
- Next by Date: Data Table Joins
- Previous by thread: Re: Load a string of CSV from memory into a dataset
- Next by thread: Re: Load a string of CSV from memory into a dataset
- Index(es):
Relevant Pages
|