tonhowtf/omniget · error

este zip não tem nenhum .csv do export do Reddit

Error message

este zip não tem nenhum .csv do export do Reddit

What it means

The zip opened successfully, but iterating its entries found no file whose name passes is_csv (Reddit export CSVs). Entries that fail to read are skipped silently, and if nothing CSV-shaped was collected the library throws this error.

Solutions

  1. Verify you are passing Reddit's own GDPR data-request zip (it contains comments.csv, posts.csv, etc.)
  2. Inspect contents: `unzip -l export.zip | grep -i csv`
  3. If the new export format uses .zst CSVs, decompress them to .csv first or point at a folder of extracted CSVs
  4. Re-export your data from Reddit if the archive is genuinely missing CSVs

Example fix

// before
path: "photos-backup.zip"  // no csv inside
// after
path: "reddit_data_request_export.zip"  // contains comments.csv, posts.csv, ...
Defensive patterns

Strategy: validation

Validate before calling

fn zip_has_csv(path: &str) -> std::io::Result<bool> {
    let f = std::fs::File::open(path)?;
    let mut z = zip::ZipArchive::new(f).map_err(std::io::Error::other)?;
    for i in 0..z.len() {
        if z.by_index(i)?.name().to_ascii_lowercase().ends_with(".csv") { return Ok(true); }
    }
    Ok(false)
}
// assert!(zip_has_csv("export.zip")?);

Prevention

When it happens

Trigger: A valid .zip that contains no .csv entries (or only unreadable ones) was passed to run().

Common situations: Selecting the wrong zip (e.g. another tool's archive); a Reddit export variant that ships .zst-compressed CSVs instead of .csv; a zip whose CSVs sit in nested formats with unexpected extensions; partially extracted/repacked archive.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/2e942fd175e1fcd5. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/reddit/gdpr.rs:278

    let file = std::fs::File::open(path)?;
    let mut zip =
        zip::ZipArchive::new(file).map_err(|e| anyhow!("não foi possível abrir o zip: {}", e))?;
    for i in 0..zip.len() {
        let mut entry = match zip.by_index(i) {
            Ok(e) => e,
            Err(_) => continue,
        };
        if !entry.is_file() || !is_csv(entry.name()) {
            continue;
        }
        let name = short_name(entry.name());
        let mut buf = Vec::new();
        if entry.read_to_end(&mut buf).is_ok() {
            out.insert(name, String::from_utf8_lossy(&buf).to_string());
        }
    }
    if out.is_empty() {
        return Err(anyhow!("este zip não tem nenhum .csv do export do Reddit"));
    }
    Ok(out)
}

fn read_text(path: &Path) -> Result<String> {
    let bytes = std::fs::read(path)?;
    Ok(String::from_utf8_lossy(&bytes).to_string())
}

// ───────────────────────── resumo ─────────────────────────

fn pick<'a>(files: &'a HashMap<String, String>, stem: &str) -> Option<&'a String> {
    files.get(&format!("{}.csv", stem)).or_else(|| {
        files
            .iter()
            .find(|(k, _)| k.starts_with(stem))
            .map(|(_, v)| v)
    })

View on GitHub (pinned to 8600b91f42)