filehelpers

FileHelpers.Dynamic.ClassBuilder.CreateRecordClass Error

寵の児 提交于 2021-02-08 12:01:21
问题 I'm trying to reading a file with layout created at runtime. But when running FixedLengthClassBuilder.CreateRecordClass (), an exception occurs: Error Compiling Expression: Line 31: The type or namespace name 'SGCompras' could not be found (are you missing a using directive or an assembly reference?). My code: public void ReadFile(string filePath){ ... var itemsLayout = Context.FixedLayouts.Where(p => p.LayoutName == "Margem").ToList(); var builder = GetFixedClass(itemsLayout, "Margem"); var

FileHelpers - Creating a field object

最后都变了- 提交于 2021-01-29 03:10:56
问题 I am trying to dynamically add field properties to a record class that I am also building dynamically using FileHelpers.Dynamic.DelimitedClassBuilder. I have no issues creating the class object and I currently add a field using the AddField(String) method. As my apps grows I now have a need to declare specific field properties in various situations. So in the same sense I wanted to use FileHelpers.Dynamic.DelimitedFieldBuilder to create a field object and then pass that to my

Why does the returned DataTable has readonly columns in FileHelpers

╄→гoц情女王★ 提交于 2020-12-05 06:46:19
问题 I am wondering why filehelpers return readonly columns. I had a huge problem with them not updating values and could not figure out why. Now I have to have another loop to go through all the columns and change them to be not readonly. Is there a way I can tell Filehelpers to not do this? So I don't have to waste time going through all of it again? 回答1: The FileHelpers class RecordOperations.CreateEmptyDataTable() method is responsible for this and it is not virtual. I think the reason might

学习ASP.NET Core Razor 编程系列十三——文件上传功能(一)

我怕爱的太早我们不能终老 提交于 2020-04-29 13:58:03
学习ASP.NET Core Razor 编程系列目录 学习ASP.NET Core Razor 编程系列一 学习ASP.NET Core Razor 编程系列二——添加一个实体 学习ASP.NET Core Razor 编程系列三——创建数据表及创建项目基本页面 学习ASP.NET Core Razor 编程系列四——Asp.Net Core Razor列表模板页面 学习ASP.NET Core Razor 编程系列五——Asp.Net Core Razor新建模板页面 学习ASP.NET Core Razor 编程系列六——数据库初始化 学习ASP.NET Core Razor 编程系列七——修改列表页面 学习ASP.NET Core Razor 编程系列八——并发处理 学习ASP.NET Core Razor 编程系列九——增加查询功能 学习ASP.NET Core Razor 编程系列十——添加新字段 学习ASP.NET Core Razor 编程系列十一——把新字段更新到数据库 学习ASP.NET Core Razor 编程系列十二——在页面中增加校验 本篇文章我们来讲在书籍信息管理系统示例使用简单的模型绑定上传文件,本文的示例适合上传小型文件。本篇文章演示如何通过单个 POST 将两个文件上传至服务器。 安全注意事项 在向用户提供向上传文件的功能时,必须格外注意安全性。

FileHelpers quote and comma in fields

旧城冷巷雨未停 提交于 2020-01-14 11:52:37
问题 I have a csv file that I am parsing with FileHelpers and I have a situation where both a quote and a comma can appear in a field: Comma: 323,"PC","28/02/2014","UNI001","5000",0,"Return","Returned Goods, damaged",88.00,15.40,"T1","N",0.00,"R","-", Quote 148,"SI","13/01/2014","CGS001","4000",1,"5","17" Monitor",266.00,45.39,"T1","Y",311.39,"R","-", My class is: [DelimitedRecord(",")] public class Transaction { public int TRAN_NUMBER; [FieldQuoted('"', QuoteMode.OptionalForBoth)] public string

Multiple CSV structures with FileHelpers

情到浓时终转凉″ 提交于 2020-01-13 05:48:53
问题 I am making a site that consumes a csv file this file can come in 2 formats(maybe more in the future). Structure 1 Header 1 Header 2 Header 3 Header 4 a b c d x x x x Structure 2 Header 1 Header 4 a d x x the above is how it would be shown in excel(if looking at raw it would be all comma separated) The reason why I want to have 2 structures is because I am using trying to leverage a 3rd party site that user can export their data from. This site exports it as a csv file with the first row

Can the FileHelpers library write classes containing nullable fields as well as read them?

巧了我就是萌 提交于 2020-01-13 02:39:09
问题 I'm using version 2.0 of the FileHelpers library which is documented as being able to handle .NET 2.0 Nullable types. I'm using the code given in the example from the documentation: [DelimitedRecord("|")] public class Orders { public int OrderID; public DateTime? OrderDate; [FieldConverter(ConverterKind.Date, "ddMMyyyy")] public DateTime? RequiredDate; public int? ShipVia; } With a FileHelperEngine I can successfully read in a file which has no value for the OrderDate, RequiredDate or ShipVia

Getting FileHelpers 2.0 to handle CSV files with excess commas

非 Y 不嫁゛ 提交于 2020-01-10 04:10:07
问题 I am currently using the FileHelpers library (v2.0.0.0) to parse a CSV file. The CSV file is mapped to a class that has a handful of public properties, let's say there are N . The problem is that, by default, FileHelpers doesn't seem to correctly handle cases where the user specifies a CSV file that has more than N-1 commas. The remaining commas just get appended to the last property value. I figured this must be configurable via FileHelpers' attributes, but I didn't see anything that would

How to return fully populated objects using FileHelpers for partially complete data?

痞子三分冷 提交于 2020-01-07 04:44:22
问题 Assume you have a CSV file with the following structure LINE1: ID,Description,Value LINE2: 1,Product1,2 LINE3: ,,3 LINE4: ,,4 LINE5: 2,Product2,2 LINE6: ,,3 LINE7: ,,5 With the corresponding FileHelpers definition class [DelimitedRecord(",") ] [IgnoreFirst(1)] public class Product { public int ID { get; set; } public string Description { get; set; } [FieldConverter(ConverterKind.Decimal)] public decimal Val{ get; set; } } How do use FileHelpers, to return objects such that each object is

FileHelpers nested quotes and commas - parsing error

时间秒杀一切 提交于 2019-12-31 04:34:26
问题 I'm trying to parse a CSV file from hell, using the fantastic FileHelpers library. It's failing to handle a row of the form: "TOYS R"" US"," INC.""",fld2,fld3,"<numberThousands>","<numberThousands>","<numberThousands>",fld7, FileHelper is very good at handling number fields in 'thousands' format (using a custom formatter), even when wrapped in quotes, trailing commas etc, however it's causing issues with the first field. "TOYS R"" US"," INC.""",fld2,... This field includes both nested quotes