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
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
1
Reply
1827
Views
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
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
3
Jun 20
|
2975 | ||
|
1
Nov 18
|
8421 | ||
|
11
Feb 17
|
62326 | ||
Import contacts through CSV
Solved
|
|
2
Mar 15
|
10092 | |
|
4
Nov 24
|
10000 |