ByteScout Barcode Reader SDK - C# - Batch Read Barcodes To CSV - ByteScout

ByteScout Barcode Reader SDK – C# – Batch Read Barcodes To CSV

  • Home
  • /
  • Articles
  • /
  • ByteScout Barcode Reader SDK – C# – Batch Read Barcodes To CSV

How to batch read barcodes to CSV in C# using ByteScout BarCode Reader SDK

This code in C# shows how to batch read barcodes to CSV with this how to tutorial

We made thousands of pre-made source code pieces for easy implementation in your own programming projects. Want to batch read barcodes to CSV in your C# app? ByteScout BarCode Reader SDK is designed for it. ByteScout BarCode Reader SDK is the SDK for reading of barcodes from PDF, images and live camera or video. Almost every common type like Code 39, Code 128, GS1, UPC, QR Code, Datamatrix, PDF417 and many others are supported. Supports noisy and defective images and docs. Includes optional documents splitter and merger for pdf and tiff based on found barcodess. Batch mode is supported for superior performance using multiple threads. Decoded values are easily exported to JSON, CSV, XML and to custom format.

You will save a lot of time on writing and testing code as you may just take the C# code from ByteScout BarCode Reader SDK for batch read barcodes to CSV below and use it in your application. In order to implement the functionality, you should copy and paste this code for C# below into your code editor with your app, compile and run your application. Detailed tutorials and documentation are available along with installed ByteScout BarCode Reader SDK if you’d like to dive deeper into the topic and the details of the API.

Trial version of ByteScout BarCode Reader SDK can be downloaded for free from our website. It also includes source code samples for C# and other programming languages.

Try ByteScout BarCode Reader SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

Program.cs
      
using System; using System.Collections.Generic; using System.Diagnostics; using Bytescout.BarCodeReader; namespace ImagePDFBarcodeToCSV { class Program { static void Main(string[] args) { try { //Read Barcode Process Reader reader = new Reader(); reader.RegistrationKey = "demo"; reader.RegistrationName = "demo"; // Set Barcode type to find reader.BarcodeTypesToFind.All = true; // Output list List<CSVOutputFormat> lstCSVOutput = new List<CSVOutputFormat>(); // Get all files in folder, and iterate through each file var files = System.IO.Directory.GetFiles("BarcodeFiles"); foreach (var fileName in files) { /* ----------------------------------------------------------------------- NOTE: We can read barcodes from specific page to increase performance . For sample please refer to "Decoding barcodes from PDF by pages" program. ----------------------------------------------------------------------- */ // Read barcodes FoundBarcode[] barcodes = reader.ReadFrom(fileName); foreach (FoundBarcode code in barcodes) { lstCSVOutput.Add(new CSVOutputFormat { barcodeValue = code.Value, barcodeType = code.Type.ToString(), scanDateTime = DateTime.Now.ToString(), fileName = fileName }); } } Console.WriteLine("Total {0} barcode found in {1} file.", lstCSVOutput.Count, files.Length); // cleanup reader.Dispose(); // Export to CSV ExportToCsv(lstCSVOutput); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine("Press enter key to exit..."); Console.ReadLine(); } /// <summary> /// Exports to CSV /// </summary> /// <param name="lstCSVOutput"></param> private static void ExportToCsv(List<CSVOutputFormat> lstCSVOutput) { System.Text.StringBuilder csvOutputContent = new System.Text.StringBuilder(string.Empty); csvOutputContent.Append("Barcode Value,Barcode Type,Scan DateTime,File Name"); foreach (var item in lstCSVOutput) { csvOutputContent.AppendFormat("\r\n{0},{1},{2},{3}", item.barcodeValue, item.barcodeType, item.scanDateTime, item.fileName); } System.IO.File.WriteAllText("output.csv", csvOutputContent.ToString()); Process.Start("output.csv"); } } class CSVOutputFormat { public string barcodeValue { get; set; } public string barcodeType { get; set; } public string scanDateTime { get; set; } public string fileName { get; set; } } }

Try ByteScout BarCode Reader SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

VIDEO

ON-PREMISE VERSION INFORMATION

Get 60 Day Free Trial or Visit ByteScout BarCode Reader SDK Home Page

Explore ByteScout BarCode Reader SDK Documentation

Get ByteScout BarCode Reader SDK Free Training

WEB API

Get Your Free API Key

Explore Web API Documentation

Tutorials:

prev
next