Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Admin/Backend] Goods list import feature #17

Open
somnisomni opened this issue Nov 1, 2023 · 1 comment · May be fixed by #56
Open

[Admin/Backend] Goods list import feature #17

somnisomni opened this issue Nov 1, 2023 · 1 comment · May be fixed by #56
Labels
enhancement New feature or request

Comments

@somnisomni
Copy link
Owner

somnisomni commented Nov 1, 2023

Idea from JCh@nmuL

Probably CSV format?
Need user guide and CSV template...

Individual goods + Goods category

When import from file
-> Parse in frontend, display parse result as dialog or something <- Send to backend, get parse result as preview from response
-> When confirmed by user, call backend API to import
-> Refresh goods / goods category data in store

@somnisomni somnisomni added the enhancement New feature or request label Nov 1, 2023
@somnisomni
Copy link
Owner Author

Experiment using csv-parse


testcsv.csv

이름,카테고리,설명,굿즈 종류,가격,초기 재고량
테스트1,카테1,설,먹을거,3000,50
테스트2,카테2,명,먹을거,6000,50
테스트3,카테2,설,볼거,2000,70
테스트4,카테1,명,먹을거,10000,20
테스트5,왈랄랄루,설,볼거,30000,40
왈랄랄루,왈랄랄루,명,볼거,27000,40

testparse.mjs

import * as csv from "csv";
import * as fs from "fs";

const record = [];
const csvparse = fs.createReadStream("./testcsv.csv").pipe(csv.parse({ autoParse: true, bom: true, columns: true }));
for await(const r of csvparse) {
  record.push(r);
}

console.log(record);

stdout

[
  {
    '이름': '테스트1',
    '카테고리': '카테1',
    '설명': '설',
    '굿즈 종류': '먹을거',
    '가격': '3000',
    '초기 재고량': '50'
  },
  {
    '이름': '테스트2',
    '카테고리': '카테2',
    '설명': '명',
    '굿즈 종류': '먹을거',
    '가격': '6000',
    '초기 재고량': '50'
  },
  {
    '이름': '테스트3',
    '카테고리': '카테2',
    '설명': '설',
    '굿즈 종류': '볼거',
    '가격': '2000',
    '초기 재고량': '70'
  },
  {
    '이름': '테스트4',
    '카테고리': '카테1',
    '설명': '명',
    '굿즈 종류': '먹을거',
    '가격': '10000',
    '초기 재고량': '20'
  },
  {
    '이름': '테스트5',
    '카테고리': '왈랄랄루',
    '설명': '설',
    '굿즈 종류': '볼거',
    '가격': '30000',
    '초기 재고량': '40'
  },
  {
    '이름': '왈랄랄루',
    '카테고리': '왈랄랄루',
    '설명': '명',
    '굿즈 종류': '볼거',
    '가격': '27000',
    '초기 재고량': '40'
  }
]

@somnisomni somnisomni linked a pull request May 30, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant