mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 19:43:41 +02:00
Merge pull request #149 from jkuhl-uni/feat/read_ms5_xsf
fix for the case that there are multiple dots in file names
This commit is contained in:
commit
2027f0003a
1 changed files with 14 additions and 9 deletions
|
@ -1061,6 +1061,10 @@ def read_ms5_xsf(path, prefix, qc, corr, sep="r", **kwargs):
|
||||||
found = []
|
found = []
|
||||||
files = []
|
files = []
|
||||||
names = []
|
names = []
|
||||||
|
|
||||||
|
if "names" in kwargs:
|
||||||
|
names = kwargs.get("names")
|
||||||
|
|
||||||
for (dirpath, dirnames, filenames) in os.walk(path + "/"):
|
for (dirpath, dirnames, filenames) in os.walk(path + "/"):
|
||||||
found.extend(filenames)
|
found.extend(filenames)
|
||||||
break
|
break
|
||||||
|
@ -1068,16 +1072,17 @@ def read_ms5_xsf(path, prefix, qc, corr, sep="r", **kwargs):
|
||||||
for f in found:
|
for f in found:
|
||||||
if fnmatch.fnmatch(f, prefix + "*.ms5_xsf_" + qc + ".dat"):
|
if fnmatch.fnmatch(f, prefix + "*.ms5_xsf_" + qc + ".dat"):
|
||||||
files.append(f)
|
files.append(f)
|
||||||
|
if "names" not in kwargs:
|
||||||
if not sep == "":
|
if not sep == "":
|
||||||
names.append(prefix + "|r" + f.split(".")[0].split(sep)[1])
|
se = f.split(".")[0]
|
||||||
|
for s in f.split(".")[1:-1]:
|
||||||
|
se += "." + s
|
||||||
|
names.append(se.split(sep)[0] + "|r" + se.split(sep)[1])
|
||||||
else:
|
else:
|
||||||
names.append(prefix)
|
names.append(prefix)
|
||||||
files = sorted(files)
|
|
||||||
|
|
||||||
if "names" in kwargs:
|
|
||||||
names = kwargs.get("names")
|
|
||||||
else:
|
|
||||||
names = sorted(names)
|
names = sorted(names)
|
||||||
|
files = sorted(files)
|
||||||
|
|
||||||
cnfgs = []
|
cnfgs = []
|
||||||
realsamples = []
|
realsamples = []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue