module parsers.ct1

Short summary

module manydataapi.parsers.ct1

Parses format from a paying machine.

source on GitHub

Functions

function

truncated documentation

dummy_ct1

Returns a dummy file for format CT1.

read_ct1

Parses a file or a string which follows a specific format called CT1. See function dummy_ct1() for an example. …

Documentation

Parses format from a paying machine.

source on GitHub

manydataapi.parsers.ct1.dummy_ct1()

Returns a dummy file for format CT1.

<<<

from manydataapi.parsers.ct1 import dummy_ct1
name = dummy_ct1()
with open(name, "r") as f:
    for i, line in enumerate(f):
        print(i, [line])
        if i > 10:
            break

>>>

    0 ['\x02HASH2\x1d216\x1dVERS\x1dVERSION\x1dCT100\n']
    1 ['H\x1d0\x1d4\x1dPERS1\x1dPLACE\x1dSTREET\x1dZIP\x1dINFO\x1d\x1d\x1d0\x1d0\x1d0\x1d0\n']
    2 ['S\x1d\x1d\x1d\n']
    3 ['L\x1d800\x1dITEM11\x1d0\x1d0\x1d1\x1d0\x1d  21.00\x1d 0.2501\x1d0\x1d    5.25\x1d      \x1d0\x1d0\x1d   0.00\x1d    0.00\n']
    4 ['L\x1d605\x1dITEM17\x1d0\x1d0\x1d1\x1d0\x1d  18.00\x1d 0.4043\x1d0\x1d    7.28\x1d      \x1d0\x1d0\x1d   0.00\x1d    0.00\n']
    5 ['L\x1d102\x1dITEM19\x1d0\x1d0\x1d1\x1d0\x1d   1.70\x1d 0.002\x1d2\x1d    3.40\x1d      \x1d0\x1d0\x1d   0.00\x1d    0.00\n']
    6 ['L\x1d3\x1dITEM1\x1d0\x1d0\x1d2\x1d0\x1d   0.31\x1d 0.001\x1d2\x1d    0.31\x1d      \x1d0\x1d0\x1d   0.00\x1d    0.00\n']
    7 ['L\x1d4\x1dITEM2\x1d0\x1d0\x1d2\x1d0\x1d   2.50\x1d 0.001\x1d2\x1d    2.50\x1d      \x1d0\x1d0\x1d   0.00\x1d    0.00\n']
    8 ['P\x1d0\x1d   18.74\n']
    9 ['T\x1d1\x1d    5.50\x1d   15.43\x1d    0.85\x1d   16.28\n']
    10 ['T\x1d2\x1d   20.00\x1d    1.50\x1d    0.30\x1d    1.80\n']
    11 ['T\x1d9\x1d   16.93\x1d    1.15\x1d   18.74\n']

source on GitHub

manydataapi.parsers.ct1.read_ct1(file_or_str, encoding='ascii', as_df=True)

Parses a file or a string which follows a specific format called CT1. See function dummy_ct1 for an example.

Parameters:
  • file_or_str – file or string

  • encoding – encoding

  • as_df – returns the results as a dataframe

Returns:

dataframe

Meaning of the columns:

  • BASKET: basket id

  • CAT: item is a quantity or a piece

  • DATETIME: date and time

  • FCODE, FCODE1, FCODE2: ?

  • HT: price with no taxes

  • INFO0, INFO1, INFO2, INFO3, INFO4, INFOL2, INFOL2_1, INFOL2_2, INFOL2_3, INFOL2_4: ?

  • IT1, IT10, IT2, IT4, IT6, IT8, IT9: ?

  • ITCODE: item code, every item ending by X is an item automatically added by the parser to fix the total

  • ITMANUAL: manually change the total

  • ITNAME: item name

  • ITPRICE: price paid

  • ITQU: quantity (kg or number of pieces)

  • ITUNIT: price per unit

  • NAME: vendor’s name

  • NB1, NB2: ?

  • NEG: some item have a negative price

  • PIECE: the quantity is a weight (False) or a number (True)

  • PLACE, STREET, ZIPCODE: location

  • TOTAL: total paid for the basket

  • TVA: tax for an item

  • TVAID: tax id

  • TVARATE: tax rate

  • ERROR: check this line later

source on GitHub