Opticon OPN2001 – CSV file data manipulation using PowerShell

CSV file RAW data should be like this =

BarCode Number, Time of Scan, Date of Scan
20120711001, 21:00:00, 2012-07-11
321530, 21:01:01, 2012-07-11
123456, 21:02:02, 2012-07-11
20120711001, 22:00:00, 2012-07-11
123456, 22:01:01, 2012-07-11
321530, 22:02:02, 2012-07-11

After the table modification with the PowerShell script, it should result as follow =

Mission ID, Person ID, Start Time, Start Date, Stop Time, Stop Date
20120711001, 20120711001, 21:00:00, 2012-07-11, 22:00:00, 2012-07-11
20120711001, 321530, 21:01:01, 2012-07-11, 22:01:01, 2012-07-11
20120711001, 123456, 21:02:02, 2012-07-11, 22:02:02, 2012-07-11

The basic PowerShell cmdlet to read and write CSV file are:

  • Import-Csv Cmdlet – Read in a Comma-Separated Values File
    Import-Csv c:\scripts\test.txt
  • Export-Csv Cmdlet – Saving Data as a Comma-Separated Values File
    Export-Csv c:\scripts\test.txt
  • Filter result before Importing
    Import-Csv c:\scripts\test.txt | Where-Object {$_.department -eq "Finance"}
  • Get-Content Cmdlet – Reading a Text File
    Get-Content c:\scripts\test.txt

    Blog example to manipulate data inside PowerShell:

  • parse-textObject
  • Typecasting imported CSV data
    import-csv test.csv | set-type -type_hash @{id=[int];workingset=[int];cpu=[float]} | ogv
  • Append column data
    Import-Csv d:\temp\so\csv1.txt -Delimiter ‘;’ | % { $_.col3 = ‘append\’ +$_.col3; $_ } | Export-Csv d:\temp\so\csv2.txt -Delimiter ‘;’
    or
    Import-Csv -Delim ';' cols.csv | Foreach {$_.col3 = "prepend\$($_.col3)";$_} | Export-Csv cols2.csv -Delim ';' -NoTypeInformation
  • Replacing Data in .CSV Field
    $SCRIPT:IMP = Import-CSV C:\Tools\PSScripts\ShellAuditSubSet.csv
    $IMP | foreach-object { $_.Message
    $CleanReturn = (CleanData ($_.Message))
    if($Messy -cne "")
    {
    $_.Message = $CleanReturn
    Write-Host "MESSAGE DATA IS " + $_.Message
    }
    }
  • Manipulate array data gathered from import-csv
  • Advertisements

    Opticon OPN2001 – Flow of bar code reader data output

    Firmware, Software and SDK is available on the Opticon website

    Barcodes.txt file is created automatically with OPN2001 x64 tool

    The format could be personalized with list of fields, best option is as follow:

    BarCode Number, Time of Scan, Date of Scan
    321530, 21:05:25, 2012-07-11
    123456, 21:06:26, 2012-07-11
    123456, 21:10:48, 2012-07-11
    321530, 21:11:49, 2012-07-11

    Need to associate a mission with a UID like YYYYmmDDnnn that should result:

    Mission ID, Person ID, Time of Scan, Date of Scan
    20120711001, 321530, 21:05:25, 2012-07-11
    20120711001, 123456, 21:06:26, 2012-07-11
    20120711001, 123456, 21:10:48, 2012-07-11
    20120711001, 321530, 21:11:49, 2012-07-11

    Procedure should be:

    1. Generate Mission ID code once confirmed, with format like YYYYmmDDnnn
    2. Print the bar code to take note of people available
    3. Once mission start, read first mission ID as marker
    4. Scan all people ID code at start
    5. Once mission end, read first mission ID as marker
    6. Scan all people ID code at end
    7. Connect to USB cable at headquarter
    8. Run the Opticon utility to download the data and create CSV file in PC
    9. Create a custom PowerShell script to modify the RAW data from this format

      BarCode Number, Time of Scan, Date of Scan
      20120711001, 21:00:00, 2012-07-11
      321530, 21:01:01, 2012-07-11
      123456, 21:02:02, 2012-07-11
      20120711001, 22:00:00, 2012-07-11
      123456, 22:01:01, 2012-07-11
      321530, 22:02:02, 2012-07-11

      After the table modification, it should result as follow:

      Mission ID, Person ID, Time of Scan, Date of Scan
      20120711001, 321530, 21:05:25, 2012-07-11
      20120711001, 123456, 21:06:26, 2012-07-11
      20120711001, 123456, 21:10:48, 2012-07-11
      20120711001, 321530, 21:11:49, 2012-07-11

    10. Then import CSV file into SharePoint automatically

    Opticon OPN2001 – Review

    Amazon Review

    I highly recommend this hand scanner. It is so much better than the CS-1504. It’s more powerful (scans smaller bar codes), hold hundreds, if not thousands more bar codes. I have both the CS-1504 and the OPTICON OPN-2001. I use the MiniPro scanner software to extract the bar codes and export to several formats.

    Scanner was code compatible with a couple minor exceptions – use Symbol documentation if you want to program directly in Java using Java Com or the OPN2001 API documentation if you want to use JNI with the OPN2001 supplied dll

    I downloaded USB drivers which work with Windows 7 64 bit. Downloaded also a firmware update; quick start guide; User manual; just all the necessary applications/drivers/other info to get this Wonderful Scanner up and running.

    Opticon OPN2001 – BarCode reader

    BarCode_Front

    BarCode_Top

    Official Opticon 2001 web

    OPN2001 – pocket memory scanner makes barcode data collection simple with 512 KB of memory, which stores over 10,000 barcodes plus time stamp.

    • Small size and light weight (30g), easy to carry.
    • One button storage, one button removal.
    • Easy data transfer through mini-USB communication interface (included).
    • Stored data is saved as a text file when transferred to the PC.
    • Internal Lithium-Ion battery charged via USB connection.

    Available on Ebay from UK for € 160

     

    Memory

     

    FlashROM

    512 kB (Program storage + >15.000 barcodes + time stamp)

    RAM

    64 kB

    Operation

     

    CPU

    ARM7 32-bit

    O/S

    Proprietary

    RTC

    Supports year, month, day, hour, minute, second (leap year supported)

    Operating indicators

     

    Visual

    1 LEDbar (red/green/orange)

    Non-visual

    Buzzer

    Operating keys

     

    Entry options

    2 keys total, 1 clear key, 1 scan key

    Communication

     

    USB

    Mini USB, Ver. 1.1

    Power

     

    Rechargeable battery

    Lithium-Ion 3.7V 150mAh

    Operating time (active)

    3.000 scans (1 scan / 5 sec)

    Operating time (idle)

    >1 year

    Charging method

    Enclosed USB cable

    Barcode scanner Optics

     

    Light source

    650 nm visible laser diode

    Scan method

    Vibrating mirror

    Scan rate

    100 scans/sec

    Reading pitch angle

    -30 to 0º, 0 to +30º

    Reading skew angle

    -50 to -8º, +8 to +50º

    Reading tilt angle

    -20 to 0º, 0 to +20º

    Curvature

    R>15 mm (EAN8), R>20 mm (EAN13)

    Min. PCS value

    0.45

    Depth of field

    60 – 570 mm / 2.36 – 22.44 in (1.0 mm / 39 mil), 40 – 360 mm / 1.57 – 14.17 in (0.5 mm / 20 mil), 40 – 220 mm / 1.57 – 8.66 in (0.25 mm / 10 mil), 40 – 120 mm / 1.57 – 4.72 in (0.15 mm / 6 mil), 50 – 100 mm / 1.97 – 3.94 in (0.127 mm / 5 mil), at PCS 0.9 UPC

    Supported Symbologies

     

    Barcode (1D)

    JAN/UPC/EAN incl. add on, Codabar/NW-7, Code 11, Code 39, Code 93, Code 128, GS1-128 (EAN-128), GS1 DataBar (RSS), IATA, Industrial 2of5, Interleaved 2of5, ISBN-ISSN, Matrix 2of5, MSI/Plessey, S-Code, Telepen, Tri-Optic, UK/Plessey

    Postal code

    Chinese Post, Korean Postal Authority code

    Durability

     

    Temperature in operation

    0 to 40 °C / 32 to 104 ºF

    Temperature in storage

    -20 to 60 ºC / -4 to 140 ºF

    Ambient light immunity

    White 3,000 lx max, Fluorescent 3,000 lx max, Direct sun 50,000 lx max

    Protection rate

    IP 42

    Physical

     

    Dimensions (w x h x d)

    32 x 62 x 16 mm / 1.26 x 2.44 x 0.63 in

    Weight body

    Ca. 28 g / 1 oz (incl. battery)

    Case

    ABS, Black

    Regulatory & Safety

     

    Product compliance

    CE, FCC, VCCI, RoHS, JIS-C-6802 Class 2, IEC 60825-1 Class 2, FDA CDRH Class II

    18 LED Car flash Strobe Light

    LightOn

     

     

    FrontOff Angle
    LightOff Cable

    Tech Spec

    Front Side

     

  • Super Bright18 LED amber-amber-amber 3 flashing mode
  • Working at 12Volt DC
  • 3 suction cups for quick screen mount
  • Adjustable angle to fit different screen
  • Power cable w/cigarette lighter adaptor
  • No wiring! No bolts! No hassle
  • Super bright , Long-lasting , Low energy helps save your power supply