PDA

View Full Version : Lianja Python and Pandas



gontran
2019-08-06, 15:43
Hello I instal pandas in my Lianja python directory it works fine I use in console :

import pandas as pd

and read my xlsx file :

df = pd.read_excel(r'C:\lianja\apps\administracion_de_s urtidos\Maestro de Productos Alpura.xlsx')

Now. How can I get the data in my 'df' Objetc?

Thanks for the help

hmischel@diligentsystems.com
2019-08-07, 09:38
Hi Gontran,

I think you would be much better off reading the excel file directly into your lianja table.
You can use
append from (https://www.lianja.com/doc/index.php/APPEND_FROM) and specify the file name and type.

That said, if there was something that you specifically needed python for, like in my case of reading individual pixel values using the opencv package, you could use Lianja.execute() to pull that data into a lianja table.

In my case, I am using numpy, but pandas should work the same way.

Here is a screenshot on how to do that.1972

gontran
2019-08-07, 11:05
Hello so nice, but now my excel files dont have images, I try to use pandas in python to open the xlsx files from excel my users use many especial characters in the excel cels, I cant convert this xlsx to cvs files this make many errors, the better idea is to read the xlsx files.
I can use the append from with xlsx files?

Or whats the best way to do this?

Thanks for the time and the advices.

hmischel@diligentsystems.com
2019-08-07, 11:23
Hi Gontran,

Can you send a sample of the xlsx file? It would be easier to troubleshoot an actual file.

Herb

gontran
2019-08-07, 11:53
Hello yes here are 3 simple examples , but many times this files have too many columns and rows.

Thanks again.

1973

HankFay
2019-08-07, 21:03
Hi Gontran,

1) what does "too many columns and rows" mean?

2) what is meant by "special characters"?

3) what is meant by "now my excel files don't have images"? If you mean cells that have images, and you want to extract the images, here's an article that shows two ways of doing that: https://www.excelhowto.com/how-to-quickly-extract-pictures-from-an-excel-file (https://www.excelhowto.com/how-to-quickly-extract-pictures-from-an-excel-file/).

hth,

Hank

gontran
2019-08-08, 10:57
Hi Hank , ok I think you mix 2 topics. I have two questions in phyton one for extracting pictures from excel files.

and other is how I can use the pandas lib for get xlsx files in native format xlsx.

the special character are comas, , , and accents, I dont whant to use cvs files.

Thas the reason because I use :

import pandas as pd
df = pd.read_excel(r'C:\lianja\apps\administracion_de_s urtidos\Maestro de Productos Alpura.xlsx')

then how I can take all data in "df" and create a tempo table?


Thanks for the help

HankFay
2019-08-08, 13:45
Hi Gontran,

Oh... It's a good idea to start a new thread for each question.

re: using Pandas -- that's not a Lianja issue, of course. Check out pandas.pydata.org for documentation. E.g., https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.read_excel.html That shows how to get your data out of the DataFrame object, and also how to filter out special characters, comments, etc.

re: creating a cursor -- given you have mentioned large numbers of records, I would likely a) work at figuring out how to import directly into a cursor and only after exhausting all possibilities look at b) creating a table with the required fields. How you proceed from there depends on the context where this will be running and the dev language you want to use.

hth,

Hank