huangwason
Programmer
I am thinking about a python script to generate a xml file from a csv file, every row in csv is an element for the generated xml file. In order to obtain file value in csv file, I used awk. In example
for i in range(int(total_line)):
elementName=os.popen("awk -F ':' 'NR==a {print $5}' a=i input.csv").read()
I'd like to fetch the ith row and 5th column value and assign it to python variable. The problem is I need to pass the python variable "i" to awk to select a line. How to solve this problem? Thanks in advance.
for i in range(int(total_line)):
elementName=os.popen("awk -F ':' 'NR==a {print $5}' a=i input.csv").read()
I'd like to fetch the ith row and 5th column value and assign it to python variable. The problem is I need to pass the python variable "i" to awk to select a line. How to solve this problem? Thanks in advance.