Support Scylla Output Files
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "plotbox"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
description = "Quick MatPlotLib base data visualizer"
|
||||
readme = "README.md"
|
||||
authors = [
|
||||
|
||||
+30
-1
@@ -1,12 +1,13 @@
|
||||
# Quick Plotter
|
||||
# Cal Wing Nov 2025
|
||||
|
||||
__version__ = "0.1.2"
|
||||
__version__ = "0.1.3"
|
||||
|
||||
import os, shutil, time, sys
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
from makegraph import makeGraph, UQ_COLOURS as UQC
|
||||
|
||||
@@ -22,6 +23,9 @@ def main():
|
||||
|
||||
data = {}
|
||||
numeric_headers = []
|
||||
# Support Scylla TXT Files
|
||||
if ".txt" not in data_path.name:
|
||||
|
||||
headers = np.genfromtxt(data_path, delimiter=",", skip_header=0, max_rows=1, dtype=str, comments="#")
|
||||
for i, header in enumerate(headers):
|
||||
data[header] = np.genfromtxt(data_path, delimiter=",", skip_header=1, max_rows=None, comments="#", dtype=float, usecols=(i,))
|
||||
@@ -30,6 +34,31 @@ def main():
|
||||
data[header] = np.genfromtxt(data_path, delimiter=",", skip_header=1, max_rows=None, dtype=str, comments="#", usecols=(i,))
|
||||
else:
|
||||
numeric_headers.append(header)
|
||||
else:
|
||||
name_line: str | None = None
|
||||
with open(data_path, "r") as fd:
|
||||
for i, line in enumerate(fd.readlines()):
|
||||
if i == 0: continue
|
||||
name_line = line
|
||||
break
|
||||
assert name_line is not None
|
||||
|
||||
headers = [h.strip() for h in name_line.split(" ") if h]
|
||||
|
||||
data_pd = pd.read_csv(
|
||||
data_path,
|
||||
skiprows = 1,
|
||||
names = headers,
|
||||
header = 0,
|
||||
sep = "\t"
|
||||
)
|
||||
|
||||
for header in headers:
|
||||
try:
|
||||
data[header] = data_pd[header].to_numpy(dtype=float)
|
||||
numeric_headers.append(header)
|
||||
except:
|
||||
data[header] = data_pd[header].to_numpy()
|
||||
|
||||
if len(numeric_headers) > 0:
|
||||
data["Index"] = tuple(range(len(data[numeric_headers[0]])))
|
||||
|
||||
Reference in New Issue
Block a user