Take data from a string CSV String C #

1

I have a small application in C # for desktop where I have a method that makes a request get that in response it receives a string with the contents of a csv file, when I already have it catched I remove the spaces with the trim method and I'm left with a string with all the fields and values separated by commas (,).

After this I have placed each field of the string in a position of a string array like this:

string[] arrayContent;
arrayContent = respCont.Split(',', ' ');

where respCont is the response from the server after the spaces have been removed with trim ().

Now I'm left with an arrangement in which I have not been able to relate the fields, in one of the lines of the file the headings of each data that will show then, would be something like this:

Date-and-time,"Encabezado-Dato1","Encabezado-Dato2","Encabezado-Dato3",
2018-08-22 14:10:00,valordato1,valordato2,valordato3,
2018-08-22 14:10:00,valordato1,valordato2,valordato3,
2018-08-22 14:10:00,valordato1,valordato2,valordato3,
2018-08-22 14:10:00,valordato1,valordato2,valordato3,
2018-08-22 14:10:00,valordato1,valordato2,valordato3,

The idea is that I could relate the values of Header-Data1 with the corresponding values of ValueDato1, but I think that this is not possible, there is some way that you can better manage this csv and be able to access this data from this way in C #.

    
asked by DVertel 28.08.2018 в 18:39
source

0 answers