Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Python programing code issue

Status
Not open for further replies.

arr_baobao

Full Member level 2
Full Member level 2
Joined
Nov 1, 2011
Messages
134
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
2,317
Hi

how to change my code so that it can work by storing each csv file i read to data_0,data_1,data_2 accordingly.
in my currently code, it will keep on replace data_i with new csv read.
how to increase the "i" value in data_i so that it will store my csv data properly.


Code Python - [expand]
1
2
3
4
5
6
7
8
#prompt user to input csv file title
 
x=input("please enter the title of your .csv file,key in 'QUIT' when done:")
i=0
while x != "QUIT":
    data_i=pd.read_csv("%s"%x)   
    i+=1
    x=input("please enter the title of your .csv file,key in 'QUIT' when done:")

 

data_i=pd.read_csv("%s"%x) should be something like

d = str("data_" + "i")
d=pd.read_csv("%s/%s"%d, %x)

Need to experiment a bit.
 

Problem is in this line

data_i=pd.read_csv("%s"%x)

this is a variable namde data_i and will never become data_0

You have to set up the directory with something like:
i = 0
d = print('data_' + '%d' % i)
and then use that d variable in your while loop.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top