Parsing and getting specific values from CSV string

Posted by Amit Ranjan on Stack Overflow See other posts from Stack Overflow or by Amit Ranjan
Published on 2010-05-20T12:33:26Z Indexed on 2010/05/20 12:50 UTC
Read the original article Hit count: 655

Filed under:

I am having a string in CSV format. Please see my earlier question http://stackoverflow.com/questions/2865861/parsing-csv-string-and-binding-it-to-listbox

I can add new values to it by some mechanism. Everything will be same except the new values will have numeric part = 0. Take example I have this exsiting CSV string

1 , abc.txt , 2 , def.doc , 3 , flyaway.txt

Now by some mechanism i added two more files Superman.txt and Spiderman.txt to the existing string. Now it became

1 , abc.txt , 2 , def.doc , 3 , flyaway.txt, 0, Superman.txt, 0 , Spiderman.txt

What i am doing here is that this csv string is paased into SP where its splitted and inserted to db. So for inserting I have to take the files with numeric part 0 only rest will be omiited .Which will be further then converted into CSV string

Array will look like this

str[0]="1" 
str[1]="abc.txt"
str[2]="2"
str[3]="def.doc "
str[4]="3" 
str[5]="flyaway.txt"
str[6]="0"
str[7]="Superman.txt"
str[8]="0" 
str[9]="Spiderman.txt"

So at last i want to say my input will be

1 , abc.txt , 2 , def.doc , 3 , flyaway.txt, 0, Superman.txt, 0 , Spiderman.txt

Desired Output:

0, Superman.txt, 0 , Spiderman.txt 

© Stack Overflow or respective owner

Related posts about vb.net