0

I want to know is there any solution to 1)use python to launch apache open office 2)open an csv file 3)Auto fill in Text Import 4)then save it into xls file.

import subprocess
subprocess.Popen('C:\Program Files (x86)\OpenOffice 4\program\soffice.exe')

Gun hanwei
  • 93
  • 1
  • 7

1 Answers1

1

Not sure why do you want to open OpenOffice with Python. But you can use pandas library to read csv and convert it to excel file.

import pandas as pd

read_file = pd.read_csv (r'Path where the CSV file is stored\File name.csv')
read_file.to_excel (r'Path to store the Excel file\File name.xlsx', index = None, header=True)
Misterlen
  • 61
  • 2
  • Hi Misterlen, Can I set the Text Import Option such as change character set to utf-8, seperator options to comma, and change all fields to text, is it possible to implement that? – Gun hanwei Oct 19 '20 at 08:28
  • You can modify or manipulate the data using pandas library and or other python libraries. read [deal with unicode](https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html#dealing-with-unicode-data) or [convert char to utf-8](https://stackoverflow.com/questions/4182603/how-to-convert-a-string-to-utf-8-in-python) – Misterlen Oct 20 '20 at 01:55