Skip to content

Commit

Permalink
Changed keys to lowercase, ReadMe update
Browse files Browse the repository at this point in the history
  • Loading branch information
garrekstemo committed Jun 23, 2022
1 parent 8e3762e commit 090d4b5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "LVM"
uuid = "76785837-0c5d-45c2-90b8-8e8ea9f9a99d"
authors = ["Garrek Stemo <8449000+garrekds@users.noreply.github.com>"]
version = "0.1.3"
version = "0.1.4"
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

Simple tool for reading `.lvm` files or other tabular data with columns that are stacked. In traditional text files, a single column represents a distinct set of data of a single unit (intensity, wavelength, etc.). For example, the first column is `x` and the second column is `y` &mdash; the `x` and `y` columns are represented by only one unit and the header (if there is one) appears at the top of the column. For some reason, I have a program that spits out data where there are columns `a`, `b`, `c`, `d` at the top, but then below these data are additional data `e` and `f`, with different units and with their own headers. The number of columns in each stack is also different, throwing up errors when trying to read these files. These `.lvm` files cannot simply be read by a program like `CSV.jl` and must be pre-processed.

This program takes these text files and returns a DataFrame for each stack of data that it finds in the file. If there are two stacks there will be a list of two DataFrames, for example.

Further data manipulation should be done with a package like `DataFrames.jl`.
This program takes these text files and returns a Julia dictionary with each real column of data as a separate key-value pair. This dictionary can easily be read by into a DataFrame using `DataFrames.jl` or similar package.

Example of the offending text file type:

Expand All @@ -21,4 +19,10 @@ D E
3 3
4 4
5 5
```

This becomes

```
Dict(:A => [0.1, 0.2, 0.3, 0.2, 0.1], :B => [...], :C => [...], :D => [...], :E => [...])
```
8 changes: 4 additions & 4 deletions src/LVM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ function read(file::String)
for (k, header) in enumerate(headers[i])

if occursin("wavelength", header)
data["Wavelength"] = chunk[:, k]
data["wavelength"] = chunk[:, k]
end
if occursin("wavenum", header)
data["Wavenumber"] = chunk[:, k]
data["wavenumber"] = chunk[:, k]
end

if occursin("CH0_diff", header)
data["DiffSignal"] = chunk[:, k]
data["diffsignal"] = chunk[:, k]
elseif occursin("CH0_", header)
data["Signal"] = chunk[:, k]
data["signal"] = chunk[:, k]
end
end

Expand Down

0 comments on commit 090d4b5

Please sign in to comment.