C# DataTable #169
-
I'm struggling to find an example of loading a .csv file to a DataTable in c#. Can you point me in the right direction? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Loading a data table could be as simple as:
However, loading the data this way will result in everything being interpreted as a string, which is likely not what you want. You can provide a schema for the data if you know what you're processing ahead of time. This uses the
If you don't know the schema ahead of time, you can use the
|
Beta Was this translation helpful? Give feedback.
-
BTW, I would suggest making a CsvDataReader.ToDatatable method. It would be a lot easier for people to discover 😉 |
Beta Was this translation helpful? Give feedback.
Loading a data table could be as simple as:
However, loading the data this way will result in everything being interpreted as a string, which is likely not what you want. You can provide a schema for the data if you know what you're processing ahead of time.
This uses the
Sylvan.Data
package which provides theSchema
type.