vendredi 10 juin 2016

Python - Adding Decimal places to elements in cvs file


when exporting a cvs file from a data simulation, we lost the decimal places that were associated with the data recorded, making our plots and values inaccurate.

When the data was collected, it was imported into excel, to where the the data was exported as a cvs. There were originally decimal values with the data (ie 1356.00000), but they were not exported with the data. I'm using a curve_fit for these values, and I have figured out the precision was greatly lost with the lost of the decimal values. So thats why I want to add decimal points with each element in the data set.

Anyway to fixing this to where all the values elements in the array are outputted as an array with decimal values?

import numpy as np
import scipy as sp
import csv

DecayTime = []
DecayCount = []

with open('Half_Life_Run_Decay.csv', 'r') as h:
    reader = csv.reader(h, delimiter=',')
    for row in reader:
        DecayTime4.append(row[0])
        DecayCount4.append(row[1])

DecayTime = np.array(DecayTime) 
DecayCount = np.array(DecayCount) 

Aucun commentaire:

Enregistrer un commentaire