Shantanu24
Posts: 19
Joined: Fri Dec 30, 2016 6:28 am

Connect Libre Office to Python

Fri Dec 30, 2016 10:21 am

Hey guys.
I am using the pyBarcode and dateandtime modules to generate a ean13 barcode that has the time and date as a string. All going well.
Now, I have 2 queries:
1. The last digit in the ean13 is changing randomly. I tried to simply add a number as a string to it as a last digit. But in vain. What may be the issue?

2. I want to now send this barcode to a Libre Office Word application for maintaining records. Is that at all possible using python?

I have a button interfaced. Everytime I press the button, a new barcode is generated. I want this to automatically be recorded into a libre office Writer. How would I go about it? Is it possible?

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Connect Libre Office to Python

Fri Dec 30, 2016 11:24 am

A1: you cannot meaningfully add a string to a number. You need to rethink the solution so you add two things of the same kind.

A2: does it have to be written to a file to be used by "Word"/LO_Writer? There are existing Python modules that can easily encode data into a .CSV file that you could then use as a spreadsheet.

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Connect Libre Office to Python

Fri Dec 30, 2016 11:44 am

Shantanu24 wrote: 1. The last digit in the ean13 is changing randomly. I tried to simply add a number as a string to it as a last digit. But in vain. What may be the issue?
The last digit is a Luhn check digit calculated from the first twelve digits.

http://www.gs1.org/check-digit-calculator
https://en.wikipedia.org/wiki/Luhn_algorithm
https://en.wikipedia.org/wiki/Hans_Peter_Luhn
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Shantanu24
Posts: 19
Joined: Fri Dec 30, 2016 6:28 am

Re: Connect Libre Office to Python

Fri Dec 30, 2016 11:58 am

B.Goode wrote:A1: you cannot meaningfully add a string to a number. You need to rethink the solution so you add two things of the same kind.

A2: does it have to be written to a file to be used by "Word"/LO_Writer? There are existing Python modules that can easily encode data into a .CSV file that you could then use as a spreadsheet.
Hello. It need not compulsorily be a file used by "Word/LO_Writer". I have managed to achieve loading data into a Spreadsheet/LO_Calc file. But I also need to add an image (.png) file. This .png file is the barcode image. I have managed to send the barcode string. But I also need to send the .png file. How is that possible?

Return to “Beginners”