I want to import scientific data from a CSV file. The data are length measurements in centimeters with uncertainties. I want to import the data with uncertainties and units into a vector - please see the code below. I can do this without units, but I am stuck how to do this with units for the whole data set. Any help is appreciated! Thanks!
Remove["Global`*"];
data=Import["data.csv","CSV", "HeaderLines"->2];
TableForm[{Transpose[data]}, TableHeadings->{None,{"x (cm)","dx(cm)"}}]
x=VectorAround[data[[All,1]],data[[All,2]]]
I want to add units (cm) to variable x. I want it to be VectorAround[{49.9 cm, 60.2 cm, 70.1 cm, 79.8 cm , 90. cm, 100.2 cm }, {0.1 cm, 0.1 cm, 0.1 cm, 0.1 cm, 0.2 cm, 0.2 cm}].
For example, I can do this manually for two data points:
x=VectorAround[{Quantity[data[[All,1]][[1]],"Centimeters"],Quantity[data[[All,1]][[2]],"Centimeters"]},{Quantity[data[[All,2]][[1]],"Centimeters"],Quantity[data[[All,2]][[2]],"Centimeters"]}]
Is there a better way to do this? This would be highly impractical to do manually with a large data set.
Quantity[]
to the entire list of data. I think it has listable attributes meaning it should operate on all members of your data list $\endgroup$data
with a few more entries, so forum participants can experiment with it. Or you can include a 1-click link to a downloadable csv file. Use an online service such as Dropbox or Google drive and make sure the link is public. Thanks. $\endgroup$Quantity
twice. $\endgroup$