Skip to content

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

License

Notifications You must be signed in to change notification settings

be-lenka/feed-sifter

Repository files navigation

🗂️ 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.


🔧 Usage

🪟 Windows

# 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

# 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:

$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:

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:

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:

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

Inspired by real-world XML product feed challenges.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published