How can I create a custom import button that take a .txt file and manipulate it using the pandas library and insert the records into a model.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilidad
- Inventario
- PoS
- Project
- MRP
Se marcó esta pregunta
1
Responder
1926
Vistas
Hi,
In this example, the fields in the text file are separated by the user-defined delimiter “/”.
# importing pandas library
import pandas as pd
# reading the given csv file
# and creating dataframe
data = pd.read_csv("file.txt", delimiter = '/')
# store dataframe into csv file
data.to_csv('file.csv', index = None)
for more info you can refer other examples in the text file contents alignments
# import csv files
csv_data = base64.b64decode(data)
data_file = io.StringIO(csv_data.decode("utf-8"))
csv_reader = csv.reader(data_file, delimiter=',')
In the above code the data will be in csv_reader you can use the data into your requirements
Regards
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
InscribirsePublicaciones relacionadas | Respuestas | Vistas | Actividad | |
---|---|---|---|---|
|
3
jun 20
|
3175 | ||
|
1
nov 18
|
8658 | ||
|
11
feb 17
|
62589 | ||
Import contacts through CSV
Resuelto
|
|
2
mar 15
|
10316 | |
|
4
nov 24
|
10326 |