I have text file with a list of numbers separated by commas, which I would like import into a notebook to be called when the name ratevector
is used. If I cut and paste the numbers manually everything works fine and the length of ratevector
matches the number of entries in the text file.
In[1]:= ratevector = {0.6951, 0, 0.6951, 1.4425, 0, 0, 1.5222, 0.6951, 4.3295, 4.3283}
Out[1]= {0.6951, 0, 0.6951, 1.4425, 0, 0, 1.5222, 0.6951, 4.3295,4.3283}
In[2]:= Length[ratevector]
Out[2]= 10
However when I import the data from the text file directly using the ReadList
or ReadString
or Import
commands ratevector
prints the correct values to the screen but the list is of length 1.
In[3]:= ratevector2 =Import["~/ratevector_testfile.txt"]
Out[3]= {.6951, 0, 0.6951, 1.4425, 0, 0, 1.5222, 0.6951, 4.3295, 4.3283}
In[4]:= Length[ratevector2]
Out[4]= 1
How can I import my data so that the 9 values are recognized? Here is a link to the file I'm trying to import, https://github.com/PrincessG/SignalNoise/blob/master/ratevector_testfile.txt. I also tried importing the file as a .CSV file. Thanks for any help you can give!
In[1376]:= testimport = Import["~/ratevectorfilename_.csv", "CSV"]
Out[1376]= {{0.6951, " 0.6951", " 1.4425", " 0", " 0", " 1.5222", " 0.6951", " 4.3295", " 4.3283"}}
In[1377]:= Length[testimport]
Out[1377]= 1