Update scripts/paraquet_conversion.R
Browse files- scripts/paraquet_conversion.R +13 -14
scripts/paraquet_conversion.R
CHANGED
|
@@ -10,7 +10,8 @@ library(arrow)
|
|
| 10 |
library(data.table)
|
| 11 |
|
| 12 |
# URL of the CSV file
|
| 13 |
-
url <- "https://huggingface.co/datasets/cjerzak/LinkOrgs/resolve/main/PosMatches_mat.csv"
|
|
|
|
| 14 |
|
| 15 |
# Temporary file path to save the downloaded CSV
|
| 16 |
temp_file <- tempfile(fileext = ".csv")
|
|
@@ -18,23 +19,21 @@ temp_file <- tempfile(fileext = ".csv")
|
|
| 18 |
# Download the CSV file
|
| 19 |
download.file(url, temp_file, mode = "wb")
|
| 20 |
|
| 21 |
-
# Read the CSV file
|
| 22 |
-
|
| 23 |
-
data <- fread(temp_file, header = FALSE)
|
| 24 |
-
|
| 25 |
-
# Add column names if needed (assuming 256 columns based on common structure)
|
| 26 |
-
if (ncol(data) == 256) {
|
| 27 |
-
setnames(data, paste("D", 1:256, sep = ""))
|
| 28 |
-
} else {
|
| 29 |
-
# Adjust based on actual number of columns
|
| 30 |
-
setnames(data, paste("V", 1:ncol(data), sep = ""))
|
| 31 |
-
}
|
| 32 |
|
| 33 |
# Write the data to Parquet format, which is efficient and preferred for large datasets on Hugging Face
|
| 34 |
-
write_parquet(data, "~/Downloads/PosMatches_mat.parquet")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
# Optional: Clean up temporary file
|
| 37 |
unlink(temp_file)
|
| 38 |
|
| 39 |
# Message
|
| 40 |
-
cat("Data has been downloaded, processed, and saved as
|
|
|
|
| 10 |
library(data.table)
|
| 11 |
|
| 12 |
# URL of the CSV file
|
| 13 |
+
#url <- "https://huggingface.co/datasets/cjerzak/LinkOrgs/resolve/main/PosMatches_mat.csv"
|
| 14 |
+
url <- "https://huggingface.co/datasets/cjerzak/LinkOrgs/resolve/main/PosMatches_mat_hold.csv"
|
| 15 |
|
| 16 |
# Temporary file path to save the downloaded CSV
|
| 17 |
temp_file <- tempfile(fileext = ".csv")
|
|
|
|
| 19 |
# Download the CSV file
|
| 20 |
download.file(url, temp_file, mode = "wb")
|
| 21 |
|
| 22 |
+
# Read the CSV file
|
| 23 |
+
data <- fread(temp_file, header = TRUE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
# Write the data to Parquet format, which is efficient and preferred for large datasets on Hugging Face
|
| 26 |
+
# write_parquet(data, "~/Downloads/PosMatches_mat.parquet")
|
| 27 |
+
|
| 28 |
+
# Write a sample
|
| 29 |
+
# samp_ <- sample(1:nrow(data),1000)
|
| 30 |
+
data <- as.data.frame(data)
|
| 31 |
+
data <- data[,colnames(data) %in% c("name1","name2","matchProb") ]
|
| 32 |
+
write_parquet(data, "~/Downloads/PosMatches_mat_sample.parquet")
|
| 33 |
+
data.table::fwrite(data, "~/Downloads/PosMatches_mat_sample.csv")
|
| 34 |
|
| 35 |
# Optional: Clean up temporary file
|
| 36 |
unlink(temp_file)
|
| 37 |
|
| 38 |
# Message
|
| 39 |
+
cat("Data has been downloaded, processed, and saved as PosMatches_mat_sample.parquet\n")
|