0

I want to convert to a single html file, several values that are inputted from a webform. This the code I have right now

formData = cgi.FieldStorage()
my_file = formData.getvalue("my_filename")
my_col = formData.getlist("column")

print(my_col) #list

for item in my_col:
    csvdata = pandas.read_csv(my_file, usecols=[item])

#cd = csvdata.to_html()
#...

Obviously this only converts to html the last item in the list. How can I convert every item in my_col list in a single html file?

1 Answer 1

1

You are only getting the last element because you are looping through my_cols. You don't need to do that, instead, send the whole list my_cols to usecols as follows and you will get the desired result.


formData = cgi.FieldStorage()
my_file = formData.getvalue("my_filename")
my_col = formData.getlist("column")

print(my_col) #list

csvdata = pandas.read_csv(my_file, usecols=my_col)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.