Comments (5)
Just pushed Sylvan.Data 0.2.0-b0001 to nuget: https://www.nuget.org/packages/Sylvan.Data/0.2.0-b0001
You'll need to catch Sylvan.Data.DataBinderException which now has an Ordinal property. The InnerException will be the FormatException that you previously caught. Let me know if that works for you and it will be included in the final 0.2.0 release.
from sylvan.
fileStream.Seek(0, SeekOrigin.Begin);
var csvDataReaderOptions = new CsvDataReaderOptions()
{
Schema = new ImportCsvSchema().Schema
};
using var streamReader = new StreamReader(fileStream, Encoding.UTF8, leaveOpen: true);
using var csvReader = CsvDataReader.Create(streamReader, csvDataReaderOptions) ;
var binder = DataBinder.Create<TParseResult>(csvReader, new DataBinderOptions() { BindingMode = DataBindingMode.AllColumns });
while (csvReader.Read())
{
try
{
binder.Bind(csvReader, parseResult);
}
catch (FormatException exception)
{
// TODO: Figure out which column was being parsed/bound
}
}
columns are mostly strings, but a few DateTimes and Decimals as follows:
new Column.Builder( nameof(CsvParseResult.Date), typeof(DateTime), allowNull: true).Build(),
new Column.Builder( nameof(CsvParseResult.Amount), typeof(decimal), allowNull: true).Build(),
Short of manually trying to parse the columns I know could have issues, I haven't found a way to get what I need from the reader, binder, or exception states.
from sylvan.
Unfortunately, there isn't currently a way to discover which column has the error. This is something I've been meaning to add though, so this is a good reminder that I need to implement it.
from sylvan.
Holy smokes, that was quick! Thank you kindly, it was exactly what I needed.
from sylvan.
If you've found these libraries useful, give it a star, helps other people find it.
from sylvan.
Related Issues (20)
- As is. The Object to CSV Writer example doesn't compile HOT 1
- Clone a CsvDataReader HOT 1
- CsvDataWriter to append to a file HOT 1
- Configuration adjustments for CSV parsing HOT 1
- Records Count and Max Length of each Column HOT 1
- A 19kb record throws CsvRecordTooLargeException HOT 3
- Fields ending in escaped character return the wrong character HOT 1
- Minor unescape issue? HOT 2
- CompiledDataBinder: "Body of catch must have the same type as body of try" exception HOT 7
- Bulk Load CSV data into Postgres? HOT 1
- DbDataReader reads all rows as empty from IEnumerable<object> HOT 5
- The ObjectDataReader should use DataMember attribute to allow column name mapping HOT 1
- Encoding problem HOT 3
- DataTable Columns and Rows HOT 3
- Reading many csv files, checking the length of fields and merging them all into one file HOT 3
- CsvWriter to output to a .gz file HOT 1
- Invalid Examples for CSV Data Binding HOT 2
- CSV: RowNumber and line breaks inside fields HOT 1
- nullables issue, how to get the property names, and type info HOT 1
- Query: Nullable boolean CsvDataWriterOptions FalseString HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sylvan.