- #1
dcrisci
- 45
- 0
So I am fairly new to Python and feel somewhat comfortable with it. I am trying to do something what I think seems kind of simple however am not too experienced with loading files into Python (or any programming language for that matter).
What I am trying to do is I have csv files that contain a bunch of Multi-channel analyzer properties in the first 21 rows and 7 columns (which I do not need to be loaded into the arrays I would like). Below these properties I have three columns for channel number, energy level, and the number of counts. I would like to load the column of counts into one numpy array and just sum them up to find the total number of counts. The coding I have this far is :
I understand this will only print the array of counts, I haven't done the summing up yet (which is just a simple numpy command) but I am getting an error for not finding the file. SOOOOO, my questions are:
What I am trying to do is I have csv files that contain a bunch of Multi-channel analyzer properties in the first 21 rows and 7 columns (which I do not need to be loaded into the arrays I would like). Below these properties I have three columns for channel number, energy level, and the number of counts. I would like to load the column of counts into one numpy array and just sum them up to find the total number of counts. The coding I have this far is :
Python:
"""
Created on Wed Apr 1 16:25:25 2015
@author: dariocrisci
"""
import numpy as np
csv = np.genfromtxt('al_five_degrees.csv', delimiter= ",")
Counts = csv[:,2]
print(Counts)
I understand this will only print the array of counts, I haven't done the summing up yet (which is just a simple numpy command) but I am getting an error for not finding the file. SOOOOO, my questions are:
1. Where do the csv files need to be saved for python to find them?
2. To only create an array of value of the number of counts, should I go into my csv files and remove the MCA properties and save them with only the three columns of values?
3. Does the coding I have to load the csv file look correct?
I have read many threads saying to use pandas but I am not familiar with this module and am trying to remain with modules I am comfortable with.2. To only create an array of value of the number of counts, should I go into my csv files and remove the MCA properties and save them with only the three columns of values?
3. Does the coding I have to load the csv file look correct?
Last edited: