0

Im trying my hand at writing my first Python tool for a part of my job to automate a process (a raffle/random drawing). I want it to ask the user 2 questions: "What month are you drawing for?" and "What year are you drawing for?"

I then want it to take the user input and load/open a csv file in the directory in python using their input.. all the csv files are titled like so..

March2019.csv
April2019.csv

So in my mind I believe that if I store those user inputs as variable I can use them to call the proper csv file

I have already tried the code shown below, but the problem is, you cant put the variables inside the '' when using the pandas.read('') function because it reads them as a string instead of as what the variables represent

month = input("What month are you drawing for? ")

year = input("What year are you drawing for? ")

import pandas
df = pandas.read_csv('month year'.csv)

this doesnt work because its literally looking for a file called 'month year'.csv

2
  • pandas.read_csv(month+year+'.csv') Commented May 16, 2019 at 3:07
  • Thank you so much, for some reason I was under the impression it all needed to be within the '' or the function wouldn't execute! Commented May 16, 2019 at 3:17

1 Answer 1

0

Try:

df = pandas.read_csv(month+str(year)+'.csv')
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.