-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added functionality for creating master index CSV
- Loading branch information
1 parent
5276987
commit 50ac150
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using CSV | ||
using DataFrames | ||
|
||
|
||
""" | ||
Create main index TSV file by combining all metadata files | ||
Parameters | ||
---------- | ||
metadata_folder::String | ||
- Folder where metadata TSVs are stored | ||
master_file::String | ||
- TSV file name for combined metadata | ||
Returns | ||
---------- | ||
nothing | ||
""" | ||
function create_master_index(metadata_folder="../metadata/"::String, | ||
master_file="../metadata/master_idx.tsv"::String) | ||
|
||
# Import all csv files into a dataframe | ||
metadata_files = [i for i in readdir(metadata_folder; join=true) if i!=master_file] | ||
df = reduce(vcat, [DataFrame(CSV.File(i, delim="|")) for i in metadata_files]) | ||
|
||
# remove duplicates | ||
df = df[findall(nonunique(df)), :] | ||
|
||
# export df | ||
CSV.write(master_file, df, delim="|") | ||
|
||
return | ||
|
||
end |