How to import and use csvkit in Python script

I feel this is a stupid question. I found the python library I need to use. In particular csvkit . I need to use this in an existing application that I created. However, the whole use case that I could see is from the command line, where the arguments are passed as follows:

in2csv ne_1033_data.xlsx > data.csv

Can I import this and use it in my application? Sort of:

from csvkit import in2csv
in2csv(ne_1033_data.xlsx, data.csv)

Thanks for helping me. I'm sure I don’t understand something ...

+4
source share
4 answers

Quote from the csvkit manual :

import csvkit

This is what you are looking for.

, python csv module. , csvkit.

+2

, convert.xls2csv:

from csvkit import convert
inputfile = open(file.csv)
convert.xls2csv(inputfile)
+1

csvkit python lib, pip install csvkit, script. API.

0

( ) , :

import csvkit
import sys
inputName = sys.argv[1]
outputName = sys.argv[2]
input = open(inputName)
output = open(outputName)
in2csv(input, output)

:

nameOfPython.py inputFile.xlsx outputFile.csv

csvkit , .

-2

All Articles