Closed jfkcooper closed 2 years ago
This probably arises from np.loadtxt
needing delimiter=","
in https://github.com/easyScience/EasyReflectometryApp/blob/552edd51d66331eae1fbd939aef91958d3bcb38d/EasyReflectometryApp/Logic/Proxies/Data.py#L195
I was about to say this exactly. I would suggest this:
else:
try:
x, y, ye, xe = np.loadtxt(file_path, unpack=True)
except ValueError:
x, y, ye = np.loadtxt(file_path, unpack=True)
xe = np.zeros_like(ye)
becomes something like
else:
if file_path[-3:] == 'csv':
try:
x, y, ye, xe = np.loadtxt(file_path, delimiter=',', unpack=True)
except ValueError:
x, y, ye = np.loadtxt(file_path, delimiter=',', unpack=True)
xe = np.zeros_like(ye)
else:
try:
x, y, ye, xe = np.loadtxt(file_path, unpack=True)
except ValueError:
x, y, ye = np.loadtxt(file_path, unpack=True)
xe = np.zeros_like(ye)
Thoughts?
Hmm, tricky since I don't think there is a "standard" where comma separated values are definitely called .CSV. Mine were .dat, and I'm sure .txt are also common, but comma and tab separators are both possible in all types (at least in my experience). Could go with insisting, or have more checks (does no throw an error if you assign three variables to a single valued array?)
Ideally, we can throw away all of the file reading code and just rely on ORSO... 🙏
I think the most friendly option will be to have some rather ugly checking code. Let me have a look today/tomorrow.
@jfkcooper do you fancy having a bash at something that would be friendly for this? (if you are too busy/don't care then I can have a go later in the week)
@jfkcooper you happy to close this issue now?
Trying to load a .dat file in csv format using the
Import data from local drive
button, nothing appears to happen and no data is loaded. Data looks like: 60_61.txt changed extension to.txt
to upload here