An open API service indexing awesome lists of open source software.

https://github.com/be-lenka/feed-sifter

Go from XML to CSV in an instant! Easily transform and reduce your XML feed to CSV, powered by PowerShell!
https://github.com/be-lenka/feed-sifter

feed google-feed xml xml-converter xml-parser

Last synced: about 1 year ago
JSON representation

Go from XML to CSV in an instant! Easily transform and reduce your XML feed to CSV, powered by PowerShell!

Awesome Lists containing this project

README

          

# πŸ—‚οΈ feed-sifter

**feed-sifter** is a lightweight, cross-platform `PowerShell` script that converts structured `XML` product feeds into flat `CSV` files.
It’s ideal for B2B/B2C product data processing, price list extraction, or automated data transformation tasks.

---

## πŸš€ Features

- βœ… Reads XML feeds from a remote **URL**
- βœ… Extracts **nested fields** (like `selling_prices`) and **root fields**
- βœ… Centralized configuration for feed structure
- βœ… Outputs clean `UTF-8` encoded `CSV`
- βœ… Runs on **Windows**, **macOS**, and **Linux** (via `PowerShell Core`)

---

## πŸ“¦ Requirements

On Windows, `PowerShell` should be installed by default.

- Windows
- On Windows: Download from https://github.com/PowerShell/PowerShell

- PowerShell Core (`pwsh`)
- On macOS/Linux: `brew install --cask powershell`

---

## πŸ”§ Usage
### πŸͺŸ Windows
```powershell
# For a CSV output
.\SiftFeedWHeader.ps1 -xmlUrl "https://example.com/path/to/feed.xml"
# For a XML output
.\SiftFeedXml.ps1 -xmlUrl "https://example.com/path/to/feed.xml"
```
### ο£Ώ MacOS
```bash
# For a CSV output
pwsh ./SiftFeedWHeader.ps1 -xmlUrl "https://example.com/path/to/feed.xml"
# For a XML output
pwsh ./SiftFeedXml.ps1 -xmlUrl "https://example.com/path/to/feed.xml"
```

### Parameters

| Parameter | Description |
|----------|-------------|
| `-xmlUrl` | **(Required)** URL of the remote XML feed you want to process |

---

## 🧠 Feed Structure Configuration

Inside the script, you can easily configure the feed structure:

```powershell
$feedStructure = @{
# XML path to repeating items
rootPath = "//item"
nestedRepeats = @{
# nested arrays
selling_prices = @("currency", "base_price", "discount_price")
}
# root-level fields
flatFields = @("ean", "availability", "availability_count")
}
```

Just modify the `flatFields` or `nestedRepeats` arrays to match your `XML` feed layout.

---

## πŸ“ Output

The resulting `output.csv` file will be written to the script's current working directory.
It contains headers and all mapped values from the `XML` feed.

Example output:

```csv
ean,availability,availability_count,currency,base_price,discount_price
20000000025,in stock,14,CZK,2500,1999
...
```

---

## πŸ’‘ Tips

- Works with `HTTPS` feeds and requires no authentication.
- To change output file name or encoding, modify the `$outputPath` and `Set-Content`/`Add-Content` lines.
- You can redirect output to a timestamped file for batch jobs.

---

## πŸ” Execution Policy Troubleshooting

If you're running the script and see an error like:

```text
File cannot be loaded because running scripts is disabled on this system.
```

This means PowerShell's **execution policy** is blocking script execution.

### βœ… Temporary Fix (Safe for Local Use)

Run this in your current terminal session **before executing the script**:

```powershell
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
```

---

## πŸ“œ License

MIT β€” free to use, modify, and distribute.
Feel free to fork and contribute!

---

## ✨ Credits

Built with πŸ’™ by [BeLenka X Barebarics](https://github.com/be-lenka)

Inspired by real-world XML product feed challenges.