I am using Apache MetaModel to get the schema information. There is one use case, where I need to create CsvDataContext
object for csv file with no header. I have column names in a separate data structure (List<String> colNames
).
The context
object gives column names as "A", "B", "C", etc
. I guess metamodel assigns some default column names to the tables with no headers.
Is there any way to modify the schema which is held by the CsvDataContext
object?
I believe UpdateableDataContext
should work, but the documentation doesn't expose any method that allows modifying the metadata like column name.
How is it possible to achieve this scenario?
When you create your
CsvDataContext
, you specify aCsvConfiguration
. One of the options in theCsvConfiguration
is to provide aColumnNamingStrategy
. The default strategy is in deed to use alphabetic characters,A
,B
,C
etc. But you can use a custom naming strategy, like this: