From 558e2f160f4a431cf1e70bc972eb45c8da2ad00c Mon Sep 17 00:00:00 2001 From: Tschan Date: Fri, 2 Oct 2026 13:28:23 +0200 Subject: [PATCH] Updating the readme file --- README.md | 14 +++++++++- defs/TOC.py | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++- main.py | 35 +++--------------------- 3 files changed, 91 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 4fc256c..52f34f5 100644 --- a/README.md +++ b/README.md @@ -136,4 +136,16 @@ Then git operates as follows: | `git add file.ext` | Stage changes in `file.ext` if it has been modified | | `git add .` | Stage changes of all modified files in `git` repo | | `git commit -m "Message"` | Commit the staged changes with the pertaining commit message "Message" | -| `git push -u origin main` | Push changes to remote on branch `main`. Normally it suffices to just run `git push`, but specifying the branches is required when there are several of them... | \ No newline at end of file +| `git push -u origin main` | Push changes to remote on branch `main`. Normally it suffices to just run `git push`, but specifying the branches is required when there are several of them... | + +To remove files from the remote repository which are not desired (i.e. wrong entry in the gitignore file), update the gitignore file and then run + +``` +git add * +git commit -m "Some commit message" +git push +git rm -r --cached +git add * +git commit -m "Some new commit message where the undesired files are now no longer there..." +git push +``` \ No newline at end of file diff --git a/defs/TOC.py b/defs/TOC.py index 15a751a..a3da451 100644 --- a/defs/TOC.py +++ b/defs/TOC.py @@ -21,6 +21,7 @@ import datetime import warnings from scipy.optimize import curve_fit from defs.Helper import compute_R2 +import re ### ----------------------------------------------------------------------------------------------------------------------------------- ### ### TOC.py @@ -358,4 +359,77 @@ class Calibration(): file.writelines(lines) def compute(self, sample_areas): - return self.curve.compute(sample_areas=sample_areas) \ No newline at end of file + return self.curve.compute(sample_areas=sample_areas) + +def TXTFileTransformer(file: Path, headline = 11, paketsize = 3, to_clipboard = True): + + methods = [] # column 1 + sample_names = [] # column 2 + comments = [] # column 6 + vials = [] # column 21 + date_times_1 = [] # column 7 + date_times_2 = [] # column 7 + date_times_3 = [] # column 7 + areas_1 = [] # column 11 + areas_2 = [] # column 11 + areas_3 = [] # column 11 + concentrations_1 = [] # column 13 + concentrations_2 = [] # column 13 + concentrations_3 = [] # column 13 + + with open(file = file, errors='ignore', mode = 'r') as f: + + for index, line in enumerate(f.readlines()): + + if index < headline: + continue + + else: + + items = re.split(r'\t', line)[:-1] + + # first sample + if (index - headline) % paketsize == 0: + + + methods.append(str(items[1])) + sample_names.append(str(items[2])) + comments.append(str(items[6])) + vials.append(int(items[21])) + + date_times_1.append(pd.to_datetime(str(items[7]), format=r'%m/%d/%Y %I:%M:%S %p')) + areas_1.append(float(items[11])) + concentrations_1.append(float(items[13])) + + # second sample + elif (index - headline) % paketsize == 1: + + date_times_2.append(pd.to_datetime(str(items[7]), format=r'%m/%d/%Y %I:%M:%S %p')) + areas_2.append(float(items[11])) + concentrations_2.append(float(items[13])) + + # third sample + elif (index - headline) % paketsize == 2: + + date_times_3.append(pd.to_datetime(str(items[7]), format=r'%m/%d/%Y %I:%M:%S %p')) + areas_3.append(float(items[11])) + concentrations_3.append(float(items[13])) + + out_frame = pd.DataFrame({'method': methods, + 'sample': sample_names, + 'comment': comments, + 'vial': vials, + 'datetime_1': date_times_1, + 'datetime_2': date_times_2, + 'datetime_3': date_times_3, + 'area_1': areas_1, + 'area_2': areas_2, + 'area_3': areas_3, + 'concentration_1': concentrations_1, + 'concentration_2': concentrations_2, + 'concentration_3': concentrations_3}) + + if to_clipboard: + out_frame.to_clipboard(excel=True, index=False) + else: + return out_frame \ No newline at end of file diff --git a/main.py b/main.py index afd7a77..6778586 100644 --- a/main.py +++ b/main.py @@ -1,33 +1,4 @@ -import matplotlib -import matplotlib.pyplot as plt +from defs.TOC import TXTFileTransformer +from pathlib import Path -matplotlib.use('pgf') -matplotlib.rcParams.update({'text.usetex': True, - 'pgf.rcfonts': False, - 'font.family': 'serif', - 'font.serif': [], - 'font.sans-serif': [], - 'font.size': 6, - #'legend.fontsize': 6, - 'legend.handlelength': 2, - #'xtick.labelsize': 6, - #'ytick.labelsize': 6, - 'pgf.texsystem': r'lualatex', - 'pgf.preamble': r'\usepackage{scrextend}' + - r'\usepackage{unicode-math}' + - r'\usepackage{accents}' + - r'\usepackage{fontspec}' + - r'\usepackage[T1]{fontenc}' + - r'\usepackage{unicode-math}' + - r'\setmainfont{STIX Two Text}' + - r'\setmathfont{STIX Two Math}' + - r'\usepackage{siunitx}' + - r'\usepackage{mhchem}' + - r'\newcommand{\der}[1]{\ensuremath{\textnormal{d}\,{#1}}}'}) - -plt.figure() -plt.plot([], label=r'$this is a very very long math label a\times b$ and some text') -plt.legend() -plt.savefig('figure.png') -plt.savefig('figure.pgf') -plt.close() \ No newline at end of file +TXTFileTransformer(file=Path(r"c:\Users\tschan_d\Documents\analysis\TOC_Analysis\20260923\20260923_DT_SOA_Extract_Measurement_01_detail.txt")) \ No newline at end of file