0

So I am trying to get python(using enthought canopy) to open a file that I saved so I can make a plot of photoelectrons. The problem is python saying there is no such file or directory.The data is on excel and saved on this waveform_data folder. Here's my code (ignore the first hello world/hello world):

import csv
import matplotlib.pyplot as plt
import numpy as np
file1=open(r'c:\Users\my_name\Documents\waveform_data\file_name') #,'rb')
data = csv.reader(file1, delimiter='\t')
x = np.arange(2000)
print x
print ("First Hello World!")
table=[row for row in data]
print ("Hello World!")
data_array = []
data_array = table 
y = data_array[:2000]
print y 
y = np.reshape(y, 2000)
for i in range (10):
    print table[i]
plt.title(r'Photoelectrons')
plt.xlabel('Time(ns)')
plt.ylabel('Voltage(v)')
plt.plot(x,y)
plt.show()

I guess my question is how do I find where the file is in my directory and open it in the correct path?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

0 Answers0