struct_post 0.1.4__tar.gz → 0.1.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: struct_post
3
- Version: 0.1.4
3
+ Version: 0.1.4.2
4
4
  Summary: A module designed to analyse common structural test results.
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "struct_post"
3
- version = "0.1.4"
3
+ version = "0.1.4.2"
4
4
  description = "A module designed to analyse common structural test results."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -4,4 +4,4 @@ from importlib import metadata
4
4
 
5
5
  __version__ = metadata.version("struct_post")
6
6
 
7
- from . import postanalysis
7
+ from . import coupon, beam, read_lvm_file
@@ -0,0 +1,70 @@
1
+ def read_lvm_file(file_name: str):
2
+ '''
3
+ Reads a LabVIEW .lvm file and returns a pandas DataFrame.
4
+
5
+ Processing steps:
6
+ - Reads the raw .lvm file as CSV text.
7
+ - Finds the last "***End_of_Header***" marker to skip metadata.
8
+ - Uses the first row after the header as column names.
9
+ - Ensures each row has the same number of entries as the header.
10
+ - Converts numeric values where possible.
11
+ - Sets the "X_Value" column as the index.
12
+
13
+ Returns:
14
+ pd.DataFrame:
15
+ DataFrame with:
16
+ - Index: "X_Value" (numeric, usually time or sample number).
17
+ - Columns: measurement channels from the .lvm file.
18
+ - Values: floats (where conversion is possible), otherwise strings.
19
+ '''
20
+ import csv
21
+ import pandas as pd
22
+ #Read the lvm file
23
+ with open(file_name, 'r') as csv_file:
24
+ csv_reader = csv.reader(csv_file)
25
+ raw_data = list(csv_reader)
26
+ # -------------------------------
27
+ # Step 1: Flatten into a list of strings
28
+ # -------------------------------
29
+ lines = []
30
+ for item in raw_data:
31
+ if item: # make sure it's not empty
32
+ lines.append(item[0]) # take the string inside
33
+ # -------------------------------
34
+ # Step 2: Find the line with the last End_of_Header
35
+ # -------------------------------
36
+ end_header_indices = []
37
+ for i, line in enumerate(lines):
38
+ if "***End_of_Header***" in line:
39
+ end_header_indices.append(i)
40
+ start_idx = end_header_indices[-1] + 1 # the line after header
41
+
42
+ # -------------------------------
43
+ # Step 3: Extract header and data
44
+ # -------------------------------
45
+ header_line = lines[start_idx]
46
+ header = header_line.split("\t")
47
+
48
+ data_lines = []
49
+ for line in lines[start_idx + 1:]:
50
+ if line.strip(): # skip empty lines
51
+ values = line.split("\t")
52
+ # Pad with empty values if too short
53
+ while len(values) < len(header):
54
+ values.append("")
55
+ data_lines.append(values)
56
+
57
+ # -------------------------------
58
+ # Step 4: Build DataFrame
59
+ # -------------------------------
60
+ df = pd.DataFrame(data_lines, columns=header)
61
+
62
+ # Convert to numeric where possible
63
+ for col in df.columns:
64
+ try:
65
+ df[col] = pd.to_numeric(df[col])
66
+ except:
67
+ pass
68
+
69
+ df = df.set_index("X_Value").iloc[:, :-1]
70
+ return df, file_name[:-4]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: struct_post
3
- Version: 0.1.4
3
+ Version: 0.1.4.2
4
4
  Summary: A module designed to analyse common structural test results.
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -4,6 +4,7 @@ pyproject.toml
4
4
  struct_post/__init__.py
5
5
  struct_post/beam.py
6
6
  struct_post/coupon.py
7
+ struct_post/read_lvm_file.py
7
8
  struct_post.egg-info/PKG-INFO
8
9
  struct_post.egg-info/SOURCES.txt
9
10
  struct_post.egg-info/dependency_links.txt
File without changes
File without changes
File without changes