Re: Load a string of CSV from memory into a dataset

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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.
>
>


.



Relevant Pages

  • Re: Load a string of CSV from memory into a dataset
    ... you should avoid writing to the disk as ... > Then run a foreach on the resulting array and split each line (array ... the csv file is being loaded into a datatable, ... >> Is it possible to skip somehow the steps where I'm writing the comma ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Best way to code the following
    ... Its not the reading or writing the CSV file which is the issue it is I cannot find an example of how to place data into a multi-demsendion array and then how to get the data back out of the arral. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Problem with a script
    ... a loop there becomes impractical. ... You still have them as uniquely named array indexes... ... writing the code twice will only ... reading your entire code and parsing it in their head, ...
    (comp.lang.php)
  • Re: Problem with a script
    ... Okay, so variables have unique labels, that doesn't mean they still couldn't be handled in a loop. ... You still have them as uniquely named array indexes... ... I believe that for the new guy this code would be readable, and identifying problems should really not be any more difficult with this, plus I think that it actually might save some time to write the actual code from the beginnig, even though it's not at it's final stage, instead of first writing everything spread out, and then rewriting the same code again cleaned. ... If you expect a person to spend an hour reading your entire code and parsing it in their head, you wont get any help and have to solve the problem by yourself. ...
    (comp.lang.php)
  • Re: problem reading/writing structures from and to files
    ... My progam can write the Data array into a binary file, after writing ... FILE *somefile; ... although the initial fwrite() -- writing bytes ...
    (comp.lang.c)