Skip to content

Commit

Permalink
post gis function reformat, removed file sig duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
CHRISCARLON committed Oct 8, 2024
1 parent e59c718 commit 18fd81b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/duckdb_load/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl DuckDBFileProcessor {
}

fn determine_file_type(file_path: &str) -> Result<FileType, Box<dyn Error>> {
// Open file
// Open file and read into buffer
let mut file = File::open(file_path)?;
let mut buffer = Vec::new();
file.read_to_end(&mut buffer)?;
Expand All @@ -69,12 +69,10 @@ impl DuckDBFileProcessor {

// Check for FileType
match header {
b"PK\x03\x04" if header.starts_with(b"PK\x03\x04") => Ok(FileType::Excel),
b"SQLite format 3\0" if header == b"SQLite format 3\0" => Ok(FileType::Geopackage),
b"\x00\x00\x27\x0A" if header.starts_with(b"\x00\x00\x27\x0A") => {
Ok(FileType::Shapefile)
}
b"PAR1" if header.starts_with(b"PAR1") => Ok(FileType::Parquet),
b"PK\x03\x04" => Ok(FileType::Excel),
b"SQLite format 3\0" => Ok(FileType::Geopackage),
b"\x00\x00\x27\x0A" => Ok(FileType::Shapefile),
b"PAR1" => Ok(FileType::Parquet),
_ if header.starts_with(b"{") => {
let json_start = std::str::from_utf8(&buffer)?;
if json_start.contains("\"type\":")
Expand Down

0 comments on commit 18fd81b

Please sign in to comment.