deckstats.net
You need to be logged in to do this.
The buttons above will open in a new window. Please return to this window after you have logged in. When you have logged in, click the Refresh Session button and then try again.

Author Topic: Feature Request: Import CSV from Snapcardster  (Read 1058 times)

Zombo

  • Patron
  • New Member
  • *****
  • Posts: 25
  • Karma: 12
  • Decks
Feature Request: Import CSV from Snapcardster
« on: March 04, 2019, 10:11:51 pm »
Could you please add a feature to import Deck lists and/or directly to collection from Snapcardster? Currently I convert the files via PowerShell.
Example (yes, the typo is really there):
Code: [Select]
Qty,Name,Printing,Foil,Alter,Signed,Condition,Languange
1,Wood Elves,CMA,,,,,
Convert Code to deckstats:
Code: [Select]
<#
Supported columns:
    card_name or Name: The card name (required)
    amount or Count: The amount
    set_code: Three-letter abbreviation of the set (eg. LEA, UST)
    language: Two-letter language code (eg. EN, DE, ES)
    condition: One/two-letter condition code (eg. NM, MP, DM)
    is_foil or Foil: Should contain a 1 if the card is foil, empty otherwise
    is_pinned: Should contain a 1 if the card is pinned, empty otherwise
    comment: A comment/notes about the card
#>

# File path variables
$source = "C:\import.txt"
$cache = "${env:temp}\temp.csv"
$target = "C:\deckstats.csv"

# CSV column layout for Deckstats
$Header = 'Count', 'Name', 'set_code', 'Foil', 'Alter', 'Signed', 'condition', 'language'

# Readin Source file from Snapcardster
$raw = Get-Content -Path $source

# Delete CSV Header Layout from Snapcardster
$raw = $raw[1..($raw.Count - 1)]

# Cache modified results in a temp file
$raw | Out-File -FilePath $cache -Force

# Readin modified file as CSV and force new columns for deckstats
$collection = Import-Csv -Path $cache -Header $Header

# Optional: Add missing information about the cards
foreach ($card in $collection) {
    $card.Condition = "NM"
    $card.language = "EN"
}

# Show the results on the command line
$collection | Format-Table

#Export
$collection | Select-Object * | Export-Csv -Path $target -NoTypeInformation

Nils

  • Hero Member
  • *****
  • Posts: 1792
  • Karma: 858
  • Decks
Re: Feature Request: Import CSV from Snapcardster
« Reply #1 on: March 09, 2019, 05:48:39 pm »
I have just updated the CSV importer to support these column names. Please give it a try and let me know whether it worked.

Btw, I think this is the first time I am actually looking at some PowerShell code. Looks pretty nice, I might need to give it a try at some point.
Please contact the user “admin” or email [email protected] if you have any questions about Deckstats!