static void Main() { //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new Form1()); Type t = GetClassType(typeof(Tools.Serialization.CSV.Customer), ","); //FileHelpers.FileHelperEngine engine = new FileHelpers.FileHelperEngine(typeof(SemicolonCustomer)); FileHelpers.FileHelperEngine engine = new FileHelpers.FileHelperEngine(t); string str = "path/to/datafile"; Tools.Serialization.CSV.Customer[] custs = (Tools.Serialization.CSV.Customer[])engine.ReadFile(str); //Customer[] custs = (Customer[]) engine.ReadFile("yourfile.txt"); foreach (Tools.Serialization.CSV.Customer cli in custs) { Console.WriteLine(); Console.WriteLine("Customer: " + cli.CustId.ToString() + " - " + cli.Name); Console.WriteLine("Added Date: " + cli.AddedDate.ToString("d-M-yyyy")); Console.WriteLine("Balance: " + cli.Balance.ToString()); Console.WriteLine(); Console.WriteLine("-----------------------------"); } // Next cli Console.WriteLine(Environment.NewLine); Console.WriteLine(" --- Press any key to continue --- "); Console.ReadKey(); }
public List <User> ExtractUsersFromNamesAndAddresses(string addressFileLocation, string nameFileLocation) { var addressEngine = new FileHelpers.FileHelperEngine <Address>(); Address[] addresses = addressEngine.ReadFile(addressFileLocation); var nameEngine = new FileHelpers.FileHelperEngine <Name>(); Name[] names = nameEngine.ReadFile(nameFileLocation); List <User> users = new List <User>(); if (names.Length == addresses.Length) { for (int i = 0; i < names.Length; i++) { users.Add( new User() { FullName = names[i].NameValue, Address = addresses[i].AddressValue }); } } //_writer.WriteAll(users); return(users); }
public string WriteReport(string Header, ArrayList l) { try { if (l == null) { return(string.Empty); } if (l.Count == 0) { return(string.Empty); } FileHelpers.FileHelperEngine engine = new FileHelpers.FileHelperEngine(l[0].GetType()); engine.HeaderText = Header; return(engine.WriteString(l)); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); throw ex; } }
// [HttpGet] // [Route("api/[action]")] public void exportCSV(CSVCourse[] theRecords) { var engine = new FileHelpers.FileHelperEngine <CSVCourse>(); engine.WriteFile("CSVOUTPUT.txt", theRecords); Console.Write("export post function"); }
public void BatchHeader_TestRowCreation() { var _suts = new List <BatchHeader>(); var _suti = new BatchHeader { ServiceClassCode = BatchServiceClassCodeConstant.Credits, CompanyName = "CONTRACTOR MGMT", CompanyDiscretionaryData = "", CompanyIdentification = "9876543210", StandardEntryClassCode = StandardEntryClassCodeConstant.PPD, CompanyEntryDescription = "SETTLEMENT", CompanyDescriptiveDate = "", EffectiveEntryDate = new DateTime(2016, 8, 11), OriginatorStatusCode = BatchHeaderOriginatorStatusCodeConstant.NonFederalGovernment, OriginatingDfi = "99889988" }; _suts.Add(_suti); var _engine = new FileHelpers.FileHelperEngine <BatchHeader>(); var _test = _engine.WriteString(_suts); var _expected = "5220CONTRACTOR MGMT 9876543210PPDSETTLEMENT 160811 1998899880000000\r\n"; Assert.Equal(_expected, _test); }
public void _01_Cotacoes_Historicas_Por_Papel_Mercado() { var motor = new FileHelpers.FileHelperEngine <CodingCraftEX06HangFire.ViewModels.Bovespa.Detail>(); var registro = motor.ReadString(linha_01).First(); Assert.AreEqual(01, registro.TipReg); Assert.AreEqual(new DateTime(2017, 1, 2), registro.DataDoPregao); Assert.AreEqual("02", registro.CodBdi); Assert.AreEqual("AALR3 ", registro.CodNeg); Assert.AreEqual(010, registro.TpMerc); Assert.AreEqual("ALLIAR ", registro.NomRes); Assert.AreEqual("ON NM", registro.Especi); Assert.AreEqual(" ", registro.PrazoT); Assert.AreEqual("R$ ", registro.ModRef); Assert.AreEqual(14.62M, registro.PreAbe); Assert.AreEqual(14.88M, registro.PreMax); Assert.AreEqual(14.40M, registro.PreMin); Assert.AreEqual(14.58M, registro.PreMed); Assert.AreEqual(14.60M, registro.PreUlt); Assert.AreEqual(14.60M, registro.PreOfc); Assert.AreEqual(14.73M, registro.PreOfv); Assert.AreEqual(00087, registro.TotNeg); Assert.AreEqual(000000000000035900, registro.QuatTot); Assert.AreEqual(0000000000523505.00M, registro.VolTot); Assert.AreEqual(0M, registro.PreExe); Assert.AreEqual(0, registro.IndOpc); Assert.AreEqual(new DateTime(9999, 12, 31), registro.DataVen); Assert.AreEqual(1, registro.FatCot); Assert.AreEqual(0, registro.PtoExe); Assert.AreEqual("BRAALRACNOR6", registro.CodIsi); Assert.AreEqual(100, registro.DisMes); }
public int FileHelpersBenchmark() { var totalLength = 0; var engine = new FileHelpers.FileHelperEngine <Record>(); var records = engine.ReadString(this.str); var numRecords = records.Length; for (var recordNum = 0; recordNum < numRecords; recordNum++) { var record = records[recordNum]; totalLength += record.Value0.Length; totalLength += record.Value1.Length; totalLength += record.Value2.Length; totalLength += record.Value3.Length; totalLength += record.Value4.Length; totalLength += record.Value5.Length; totalLength += record.Value6.Length; totalLength += record.Value7.Length; totalLength += record.Value8.Length; totalLength += record.Value9.Length; } return(totalLength); }
public static Respondent[] LoadRespondentsFromFile() { const string csvPath = @"sporgeskema3.csv"; var reader = new FileHelpers.FileHelperEngine<Respondent> { Options = { IgnoreFirstLines = 2 } }; var respondents = reader.ReadString(ReadFromAssemblyResource(Assembly.GetExecutingAssembly(), csvPath)); return respondents; }
static void Main(string[] args) { rec record = new rec { id = 1, mydecimal = null }; List<rec> records = new List<rec> { record }; FileHelpers.FileHelperEngine<rec> engine = new FileHelpers.FileHelperEngine<rec>(); Console.WriteLine(engine.WriteString(records)); }
public void _00_Header() { var motor = new FileHelpers.FileHelperEngine <CodingCraftEX06HangFire.ViewModels.Bovespa.Header>(); var registro = motor.ReadString(linha_00).First(); Assert.AreEqual(0, registro.TipoDeRegistro); Assert.AreEqual("COTAHIST.2017", registro.NomeDoArquivo); Assert.AreEqual("BOVESPA ", registro.CodigoDaOrigem); Assert.AreEqual(new DateTime(2017, 9, 1), registro.DataDaGeracaoDoArquivo); Assert.AreEqual("".PadLeft(214), registro.Reserva); }
public void ImportRows() { FileHelpers.FileHelperEngine engine = new FileHelpers.FileHelperEngine(typeof(GitUser)); GitUser[] res = engine.ReadFile(dataLocation) as GitUser[]; List <IdentRow> users = new List <IdentRow>(); foreach (GitUser user in res) { new IdentRow(DSType, user.ident, user.name, user.name, normalizeRole(user.role)).StoreRow(); } }
private void ReadFileHeader(string fileName) { fileEngine = new FileHelpers.FileHelperEngine(typeof(CetipFileHeader)); CetipFileHeader[] headerContent = fileEngine.ReadFile(fileName, 1) as CetipFileHeader[]; if (headerContent != null) { gridHeader.Visible = true; gridHeader.DataSource = headerContent; } }
public void _99_Trailer() { var motor = new FileHelpers.FileHelperEngine <CodingCraftEX06HangFire.ViewModels.Bovespa.Trailer>(); var registro = motor.ReadString(linha_99).First(); Assert.AreEqual(99, registro.TipoDeRegistro); Assert.AreEqual("COTAHIST.2017", registro.NomeDoArquivo); Assert.AreEqual("BOVESPA ", registro.CodigoDaOrigem); Assert.AreEqual(new DateTime(2017, 9, 1), registro.DataDaGeracaoDoArquivo); Assert.AreEqual(00000323986, registro.TotalDeRegistros); Assert.AreEqual("".PadRight(203), registro.Reserva); }
private void DoWork() { String OutPath = @"C:\Users\Aaron\Documents\Visual Studio 2013\Projects\IdentMatrix\IdentMatrix\alerts.txt"; TextADDataSource ad = new TextADDataSource(); TextGITDataSource git = new TextGITDataSource(); ad.ImportRows(); git.ImportRows(); FileHelpers.FileHelperEngine engine = new FileHelpers.FileHelperEngine(typeof(Alerts)); engine.AppendToFile(OutPath, new Alerts("Hi")); }
public void FileControl_TestRowCreation() { var _suts = new List <FileControl>(); var _sut = new FileControl(); _suts.Add(_sut); var _engine = new FileHelpers.FileHelperEngine <FileControl>(); var _test = _engine.WriteString(_suts); var _expected = "9000000000000000000000000000000000000000000000000000000 \r\n"; Assert.Equal(_expected, _test); }
private void ReadFileContent(string fileName) { CetipFileRecord[] content = null; fileEngine = new FileHelpers.FileHelperEngine(typeof(CetipFileRecord)); fileEngine.Options.IgnoreFirstLines = 1; fileEngine.Options.IgnoreEmptyLines = true; content = fileEngine.ReadFile(fileName) as CetipFileRecord[]; if (content != null) { gridConteudo.Visible = true; gridConteudo.DataSource = content; } }
/// <summary> /// Metodo para leer el archivo y persistirlo en la BD /// <remarks> /// Este método debería guardar un diferencial diariamente. /// Ahora mismo solo vacia el contenido completo. /// </remarks> /// </summary> public void ImportarArchivo() { var parseEngine = new FileHelpers.FileHelperEngine<Models.RncMapper>(); var rncs = parseEngine.ReadFile(Common.RutaArchivoCsv); //TODO: Aqui deberiamos usar un método ASYNC para ir enviando mensajes de progreso var dbRncList = new List<Models.RNC>(); for (int i = 0; i < rncs.Length ; i++) { var item = rncs[i]; DateTime fecha; var dbItem = new Models.RNC { NumeroRnc = item.NumeroRnc, RazonSocial = item.RazonSocial, NombreComercial = item.NombreComercial, ActividadPrincipal = item.ActividadPrincipal, DireccionCalle = item.DireccionCalle, DireccionNumero = item.DireccionNumero, DireccionSector = item.DireccionSector, Telefono = item.Telefono, RegimenPago = item.RegimenPago, Estado = item.Estado }; if (DateTime.TryParseExact(item.FechaConstitucion, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out fecha)) { dbItem.FechaConstitucion = fecha; } dbRncList.Add(dbItem); } //TODO: Ahora mismo está todo en un método, hay que separar las tareas de parsing de las de escritura en la BD var context = new Database(); //Prueba con los primeros cinco mil registros foreach (var rnc in dbRncList.Take(5000)) { context.ListadoRNCs.Add(rnc); } context.SaveChanges(); }
public void BatchControl_TestRowCreation() { var _suts = new List <BatchControl>(); var _suti = new BatchControl { CompanyIdentification = "9876543210", OriginatingDfi = "99889988", TotalCreditAmount = 9223372036854775807, TotalDebitAmount = 9223372036854775807 }; _suts.Add(_suti); var _engine = new FileHelpers.FileHelperEngine <BatchControl>(); var _test = _engine.WriteString(_suts); var _expected = "820000000000000000009223372036859223372036859876543210 998899880000000\r\n"; Assert.Equal(_expected, _test); }
public async Task ExportCsvToMySQL <T>(string myDirPath) where T : class { using (var db = new TrainsDb_200123Context()) { DirectoryInfo d = new DirectoryInfo(myDirPath); //Assuming Test is your Folder FileInfo[] Files = d.GetFiles("*.csv"); foreach (FileInfo file in Files) { FileHelpers.FileHelperEngine <T> engine = new FileHelpers.FileHelperEngine <T>(Encoding.GetEncoding("ISO-8859-1")); engine.HeaderText = engine.GetFileHeader().Remove(0, 3); engine.ErrorManager.ErrorMode = FileHelpers.ErrorMode.SaveAndContinue; T[] trains = engine.ReadFile(file.FullName); //Array.ForEach(trains, e => e.Id = 0); await db.AddRangeAsync(trains); await db.SaveChangesAsync(); /* * int count = 0; * foreach (var train in trains) * { * count++; * train.Id = 0; * db.CzPreosGtn.Add(train); * db.SaveChanges(); * } */ if (engine.ErrorManager.HasErrors) { engine.ErrorManager.SaveErrors($"{myDirPath}\\err-{file.Name}.out"); } Console.WriteLine($"Importet file: {file.Name}"); //Console.WriteLine($"Records: {count}"); //ReadFileLineByLine(db, file); } Console.WriteLine($"finished: {myDirPath}"); return; } }
static void Main() { //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new Form1()); Type t = GetClassType(typeof(Tools.Serialization.CSV.Customer), ","); //FileHelpers.FileHelperEngine engine = new FileHelpers.FileHelperEngine(typeof(SemicolonCustomer)); FileHelpers.FileHelperEngine engine = new FileHelpers.FileHelperEngine(t); // To read use: string str = @"D:\Stefan.Steiger\Documents\Visual Studio 2010\Projects\MvcExamples\FileHelpers_Examples_CSharp_VbNet\Data\SemicolonCustomers.txt"; str = @"D:\Stefan.Steiger\Documents\Visual Studio 2010\Projects\MvcExamples\FileHelpers_Examples_CSharp_VbNet\Data\CustomersDelimited.txt"; //str = @"D:\Stefan.Steiger\Desktop\FileHelpers_Examples_CSharp_VbNet\Data\CustomersDelimited.txt"; Tools.Serialization.CSV.Customer[] custs = (Tools.Serialization.CSV.Customer[])engine.ReadFile(str); //Customer[] custs = (Customer[]) engine.ReadFile("yourfile.txt"); foreach (Tools.Serialization.CSV.Customer cli in custs) { Console.WriteLine(); Console.WriteLine("Customer: " + cli.CustId.ToString() + " - " + cli.Name); Console.WriteLine("Added Date: " + cli.AddedDate.ToString("d-M-yyyy")); Console.WriteLine("Balance: " + cli.Balance.ToString()); Console.WriteLine(); Console.WriteLine("-----------------------------"); } // Next cli Console.WriteLine(Environment.NewLine); Console.WriteLine(" --- Press any key to continue --- "); Console.ReadKey(); }
public void FileHeader_TestRowCreation() { var _suts = new List <FileHeader>(); var _suti = new FileHeader { ImmediateOriginName = "Test Company Name", ImmediateDestinationName = "Bank of America DAL", CreationDate = DateTime.Now, CreationTime = DateTime.Now, Id = "A", ImmediateDestination = " 123456789", ImmediateOrigin = "9996663331", ReferenceCode = "ref#" }; _suts.Add(_suti); var _engine = new FileHelpers.FileHelperEngine <FileHeader>(); var _test = _engine.WriteString(_suts); var _timestamp = _suti.CreationDate.ToString("yyMMdd") + _suti.CreationTime.ToString("HHmm"); var _expected = "101 1234567899996663331" + _timestamp + "A094101Bank of America DAL Test Company Name ref# \r\n"; Assert.Equal(_expected, _test); }
public void Entry_TestRowCreation() { var _suts = new List <Entry>(); var _suti = new Entry(StandardEntryClassCodeConstant.CCD) { Amount = 99988, AddendaRecordIndicator = (short)AddendaRecordIndicatorEnum.NotIncluded, CheckDigit = "8", RdfiAccountNumber = "44556677", DiscretionaryData = "", ReceiverIdentificationNumber = "ID#Something", RdfiRtn = "99887766", ReceiverName = "Receiving Company Name", TransactionCode = (short)TransactionCodeEnum.AutomatedDepositChecking }; _suts.Add(_suti); var _engine = new FileHelpers.FileHelperEngine <Entry>(); var _test = _engine.WriteString(_suts); var _expected = "62299887766244556677 99988ID#Something Receiving Company Name 0 \r\n"; Assert.Equal(_expected, _test); }
private static Category[] GetCategories(string filename) { FileHelpers.FileHelperEngine<Category> engineCat = new FileHelpers.FileHelperEngine<Category>(); return engineCat.ReadFile(filename); }
public void Airlines() { var engine = new FileHelpers.FileHelperEngine<BigDataData.Csv.Airline>(); var result = engine.ReadFile(@"D:\stuff\datasource\airlines.csv"); try { foreach (BigDataData.Csv.Airline air in result) { context.AddAirline(new BigDataData.Models.Airline { ImportedId = air.AirlineId, Name = air.Name, Alias = air.Alias, Iata = air.Iata, Icao = air.Icao, Callsign = air.Callsign, Country = air.Country, Active = air.Active }); } } catch (Exception eek) { Console.WriteLine("Save error: {0}", eek.Message); } }
public int FileHelpers() { var totalLength = 0; if (Columns == 10) { var engine = new FileHelpers.FileHelperEngine <Record10>(); var records = engine.ReadString(StringFile); var numRecords = records.Length; for (var recordNum = 0; recordNum < numRecords; recordNum++) { var record = records[recordNum]; totalLength += record.column1.Length; totalLength += record.column2.Length; totalLength += record.column3.Length; totalLength += record.column4.Length; totalLength += record.column5.Length; totalLength += record.column6.Length; totalLength += record.column7.Length; totalLength += record.column8.Length; totalLength += record.column9.Length; totalLength += record.column10.Length; } return(totalLength); } else { var engine = new FileHelpers.FileHelperEngine <Record50>(); var records = engine.ReadString(StringFile); var numRecords = records.Length; for (var recordNum = 0; recordNum < numRecords; recordNum++) { var record = records[recordNum]; totalLength += record.column1.Length; totalLength += record.column2.Length; totalLength += record.column3.Length; totalLength += record.column4.Length; totalLength += record.column5.Length; totalLength += record.column6.Length; totalLength += record.column7.Length; totalLength += record.column8.Length; totalLength += record.column9.Length; totalLength += record.column10.Length; totalLength += record.column11.Length; totalLength += record.column12.Length; totalLength += record.column13.Length; totalLength += record.column14.Length; totalLength += record.column15.Length; totalLength += record.column16.Length; totalLength += record.column17.Length; totalLength += record.column18.Length; totalLength += record.column19.Length; totalLength += record.column20.Length; totalLength += record.column21.Length; totalLength += record.column22.Length; totalLength += record.column23.Length; totalLength += record.column24.Length; totalLength += record.column25.Length; totalLength += record.column26.Length; totalLength += record.column27.Length; totalLength += record.column28.Length; totalLength += record.column29.Length; totalLength += record.column30.Length; totalLength += record.column31.Length; totalLength += record.column32.Length; totalLength += record.column33.Length; totalLength += record.column34.Length; totalLength += record.column35.Length; totalLength += record.column36.Length; totalLength += record.column37.Length; totalLength += record.column38.Length; totalLength += record.column39.Length; totalLength += record.column40.Length; totalLength += record.column41.Length; totalLength += record.column42.Length; totalLength += record.column43.Length; totalLength += record.column44.Length; totalLength += record.column45.Length; totalLength += record.column46.Length; totalLength += record.column47.Length; totalLength += record.column48.Length; totalLength += record.column49.Length; totalLength += record.column50.Length; } return(totalLength); } }
public static void Main(string[] args) { var options = new Options(); CommandLine.ICommandLineParser cmdParser = new CommandLine.CommandLineParser(new CommandLine.CommandLineParserSettings(System.Console.Error)); if (cmdParser.ParseArguments(args, options)) { string connectionString = string.Format("URI=file:{0}", options.Database); #if (NET) var connection = new System.Data.SQLite.SQLiteConnection(connectionString); #else var connection = new Mono.Data.Sqlite.SqliteConnection(connectionString); #endif connection.Open(); var command = connection.CreateCommand(); command.CommandText = "CREATE TABLE IF NOT EXISTS at (id INTEGER PRIMARY KEY NOT NULL,name VARCHAR,surname VARCHAR,year INTEGER,gender CHAR,time VARCHAR)"; command.ExecuteNonQuery(); var repo = new AthleteRepository(command); switch (options.Action) { case Action.Module: { // 10mm d=> 28pt // 15mm => 42pt //float marginLeft, float marginRight, float marginTop, float marginBottom var document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 10, 10, 36, 36); iTextSharp.text.pdf.PdfWriter.GetInstance(document, new System.IO.FileStream("./module.pdf", System.IO.FileMode.Create)); document.Open(); var builder = new ModuleBuilder(document, options.YearEdition, 10); for (int page = 0; page < 10; page++) { builder.AddPage(); } document.Close(); break; } case Action.Insert: { System.Console.WriteLine("Drop all results?[y/N]?"); string yes = System.Console.ReadLine(); if (yes == "y") { FileHelpers.FileHelperEngine<Athlete> engine = new FileHelpers.FileHelperEngine<Athlete>(); Athlete[] athletes = engine.ReadFile(options.Input); repo.DeleteAll(); foreach (var a in athletes) { System.Console.WriteLine(a.Name); repo.Insert(a); } } break; } case Action.CreateList: case Action.CreateResult: { string catFileName = GetCatFileName(options); string reportFileName = GetReportFileName(options); var document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 10, 10, 36, 36); iTextSharp.text.pdf.PdfWriter.GetInstance(document, new System.IO.FileStream(reportFileName, System.IO.FileMode.Create)); document.Open(); IBuilder builder = null; if (options.Action == Action.CreateList) { builder = new ListBuilder(document); } else { builder = new PdfBuilder(document); } Category[] cats = GetCategories(catFileName); foreach (Category cat in cats) { if (log.IsDebugEnabled) log.Debug("parse" + cat.Id); builder.BeginReport(cat.Title, options.YearEdition); var athletes = repo.Query(string.Format (cat.Sql, options.YearEdition)); foreach (Athlete athlete in athletes) { builder.Add(athlete); } builder.EndReport(); } document.Close(); break; } case Action.Interactive: { Category[] cats = GetCategories(GetCatFileName(options)); var parser = new TimeParser(); foreach (Category cat in cats) { System.Console.WriteLine("========{0}=========", cat.Id); var athletes = repo.Query(string.Format (cat.Sql, options.YearEdition)); foreach (Athlete athlete in athletes) { System.Console.Write("{0:00} {1}\t{2}({3}):", athlete.Id, athlete.Surname, athlete.Name, athlete.Gender); string time = string.Empty; string fmt = string.Empty; do { time = System.Console.ReadLine(); fmt = parser.Parse(time); if (!string.IsNullOrEmpty(fmt) ) { System.Console.WriteLine(fmt); repo.UpdateTime(athlete.Id, fmt); } else { if (time != "s") { System.Console.WriteLine("invalid.."); } } } while (string.IsNullOrEmpty(fmt) && time != "s"); } } break; } } connection.Close(); } }
public void File_TestHarness() { var _output = new StringBuilder(); var _file = new File(); _file.Header.Id = "A"; _file.Header.ImmediateDestination = " 091000019"; _file.Header.ImmediateDestinationName = "WELLS FARGO"; _file.Header.ImmediateOrigin = "9876543210"; _file.Header.ImmediateOriginName = "Contractor Mgmt Srvcs"; _file.Header.ReferenceCode = ""; _file.AddBatch(new Batch()); _file.Batches[0].Header.CompanyName = "Contractor Mgmt"; _file.Batches[0].Header.CompanyIdentification = "9876543210"; _file.Batches[0].Header.StandardEntryClassCode = StandardEntryClassCodeConstant.CCD; _file.Batches[0].Header.CompanyEntryDescription = "SETTLEMENT"; _file.Batches[0].Header.EffectiveEntryDate = DateTime.Now; _file.Batches[0].Header.OriginatingDfi = "09100001"; _file.Batches[0].AddEntry(new Entry(StandardEntryClassCodeConstant.CCD) { Amount = 99988, AddendaRecordIndicator = (short)AddendaRecordIndicatorEnum.NotIncluded, CheckDigit = "8", RdfiAccountNumber = "44556677", DiscretionaryData = "", ReceiverIdentificationNumber = "ID#Something1", RdfiRtn = "99887766", ReceiverName = "Receiving Company Name1", TransactionCode = (short)TransactionCodeEnum.AutomatedDepositChecking }); _file.Batches[0].AddEntry(new Entry(StandardEntryClassCodeConstant.CCD) { Amount = 1250233, AddendaRecordIndicator = (short)AddendaRecordIndicatorEnum.NotIncluded, CheckDigit = "8", RdfiAccountNumber = "11223344", DiscretionaryData = "", ReceiverIdentificationNumber = "ID#Something2", RdfiRtn = "99887766", ReceiverName = "Receiving Company Name2", TransactionCode = (short)TransactionCodeEnum.AutomatedDepositSavings }); var _fileHeaders = new List <FileHeader>(); _fileHeaders.Add(_file.Header); var _engine = new FileHelpers.FileHelperEngine <FileHeader>(); _output.Append(_engine.WriteString(_fileHeaders)); foreach (var batch in _file.Batches) { var _batchHeaders = new List <BatchHeader>(); _batchHeaders.Add(batch.Header); var _batchEngine = new FileHelpers.FileHelperEngine <BatchHeader>(); _output.Append(_batchEngine.WriteString(_batchHeaders)); var _entries = new List <Entry>(); foreach (var entry in batch.Entries) { _entries.Add(entry); } var _entryEngine = new FileHelpers.FileHelperEngine <Entry>(); _output.Append(_entryEngine.WriteString(_entries)); var _batchControls = new List <BatchControl>(); _batchControls.Add(batch.Control); var _batchControlEngine = new FileHelpers.FileHelperEngine <BatchControl>(); _output.Append(_batchControlEngine.WriteString(_batchControls)); } var _fileControls = new List <FileControl>(); _fileControls.Add(_file.Control); var _fileControlEngine = new FileHelpers.FileHelperEngine <FileControl>(); _output.Append(_fileControlEngine.WriteString(_fileControls)); // do we want our own "checksum" System.IO.File.WriteAllText(@"C:\NachaTest.txt", _output.ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="FlatFileReaderHelper<TSource, TDestination>"/> class. /// </summary> public FlatFileReaderHelper() { fileEngine = new FileHelpers.FileHelperEngine <TSource>(); }
private void ParseFile(String filename, TermCSV csv, String languageCd) { int countEntries = 0; int countAxis = 0; var engine = new FileHelpers.FileHelperEngine<ATC_Entry>(); List<ATC_Entry> entries = engine.ReadFileAsList(filename); List<String> codeList = new List<string>(); TermCSVEntry currentAxis = null; foreach (ATC_Entry atc_entry in entries) { if (atc_entry == null || string.IsNullOrEmpty(atc_entry.ATC_CODE)) continue; if (atc_entry.ATC_CODE.Length == 1) { currentAxis = new TermCSVEntry(); currentAxis.Code = atc_entry.ATC_CODE; currentAxis.Term = atc_entry.BEDEUTUNG; currentAxis.IsAxis = true; currentAxis.IsMainclass = false; currentAxis.IsPreferred = true; currentAxis.Metadata.Add("DDD-INFO", atc_entry.DDD_INFO); csv.Entries.Add(currentAxis); countAxis++; codeList.Add(atc_entry.ATC_CODE); continue; } if (currentAxis != null) { TermCSVEntry entry = new TermCSVEntry(); entry.Code = atc_entry.ATC_CODE; entry.Term = atc_entry.BEDEUTUNG; entry.IsAxis = false; entry.IsMainclass = false; entry.AssociationKind = "2"; entry.AssociationType = "is part of"; entry.AssociationTypeReverse = "is parent of"; entry.IsPreferred = true; String code = atc_entry.ATC_CODE; while(code.Length > 0) { code = code.Substring(0, code.Length - 1); if(codeList.Contains(code)) { entry.RelationCode = code; break; } } entry.Metadata.Add("DDD-INFO", atc_entry.DDD_INFO); csv.Entries.Add(entry); countEntries++; if (codeList.Contains(atc_entry.ATC_CODE)) { // WARNING codeList.Add(atc_entry.ATC_CODE); } else codeList.Add(atc_entry.ATC_CODE); //Console.WriteLine("Found code: " + entry.Code + ", Term: " + entry.Term); } } Console.WriteLine("File imported. Axis count: " + countAxis + ", Entry count: " + countEntries); }
public static void SaveRespondentsToFile(string path, IEnumerable<Respondent> respondents) { var header = new string[] {"RespondentID","CollectorID","StartDate","EndDate","IpAddress","Postnummer","Email","Age","NumberOfRunsPerWeek","NumberOfRunsPerWeekComment","NumberOfYearsRunning","NumberOfYearsRunningComment","GoalText","Goal","NumberOfShoes","UsesTrainingpeaksCom","UsesIformDk","UsesDinFormDk","UsesToolFromPulseWatch","UsesNoTrainingTool","UsesOtherTrainingToolComment","RegisterRunDataWeight","RegisterShoeDataWeight","FetchDataFromWatchWeight","TrainerWeight","StatisticsBestRunsWeight","VisualWeightlossWeight","CompareResultsWithOthersWeight","RunCalendarWeight","TrainingProgramOtherWishesComment","MonthlyPayment","MonthlyPaymentText","WantsTrialProgramEdition"}; var writer = new FileHelpers.FileHelperEngine<Respondent> {HeaderText = string.Join("\t", header)}; writer.WriteFile(path,respondents); }
public void Aiports() { var engine = new FileHelpers.FileHelperEngine<BigDataData.Csv.Airport>(); var result = engine.ReadFile(@"D:\stuff\datasource\airports.csv"); try { foreach (BigDataData.Csv.Airport air in result) { context.AddAirport(new BigDataData.Models.Airport { ImportedId = air.AirportId, Altitude = air.Altitude, City = air.City, Country = air.Country, Dst = air.Dst, IataFaa = air.IataFaa, Icao = air.Icao, Latitude = air.Latitude, Longitude = air.Longitude, Name = air.Name, Timezone = air.Timezone, TzDatabaseTimeZone = air.TzDatabaseTimeZone }); } } catch (Exception eek) { Console.WriteLine("Save error: {0}", eek.Message); } Console.WriteLine("Done"); Console.ReadKey(); }