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

数据修正建议 #6

Open
yindz opened this issue Apr 16, 2021 · 1 comment
Open

数据修正建议 #6

yindz opened this issue Apr 16, 2021 · 1 comment

Comments

@yindz
Copy link

yindz commented Apr 16, 2021

要满足真实场景使用的话,有小部分数据是需要修正的(如繁简转换,属相不准确等)。我自己通过数据库方式做了修正,语句如下:

CREATE TABLE tmp_calendar(dayvarchar(255) DEFAULT NULL,gregorianYearvarchar(255) DEFAULT NULL,gregorianMonthvarchar(255) DEFAULT NULL,gregorianDatevarchar(255) DEFAULT NULL,lunarYearvarchar(255) DEFAULT NULL,lunarMonthvarchar(255) DEFAULT NULL,lunarDatevarchar(255) DEFAULT NULL,lunarLeapMonthvarchar(255) DEFAULT NULL,solarTermvarchar(255) DEFAULT NULL,zodiac` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

#导入
LOAD DATA INFILE '/path-to/all.csv'
INTO TABLE tmp_calendar
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';

#修正
UPDATE tmp_calendar SET lunarMonth=REPLACE(lunarMonth, '閏', '闰');
UPDATE tmp_calendar SET solarTerm=REPLACE(solarTerm, '驚蟄', '惊蛰');
UPDATE tmp_calendar SET solarTerm=REPLACE(solarTerm, '穀雨', '谷雨');
UPDATE tmp_calendar SET solarTerm=REPLACE(solarTerm, '小滿', '小满');
UPDATE tmp_calendar SET solarTerm=REPLACE(solarTerm, '芒種', '芒种');
UPDATE tmp_calendar SET solarTerm=REPLACE(solarTerm, '處暑', '处暑');
UPDATE tmp_calendar SET zodiac=REPLACE(zodiac, '龍', '龙');
UPDATE tmp_calendar SET zodiac=REPLACE(zodiac, '馬', '马');
UPDATE tmp_calendar SET zodiac=REPLACE(zodiac, '雞', '鸡');
UPDATE tmp_calendar SET zodiac=REPLACE(zodiac, '豬', '猪');
UPDATE tmp_calendar SET zodiac=REPLACE(zodiac, '犬', '狗');
UPDATE tmp_calendar SET zodiac='鸡' WHERE zodiac='' AND lunarYear LIKE '%酉';

#重新导出
SELECT 'day','gregorianYear','gregorianMonth','gregorianDate','lunarYear','lunarMonth','lunarDate','lunarLeapMonth','solarTerm','zodiac' FROM DUAL
UNION
SELECT day,gregorianYear,gregorianMonth,gregorianDate,lunarYear,lunarMonth,lunarDate,lunarLeapMonth,solarTerm,zodiac FROM tmp_calendar
INTO OUTFILE '/path-to/new.csv'
FIELDS
TERMINATED BY ','
LINES
TERMINATED BY '\n';

DROP TABLE tmp_calendar;
`

@hungtcs
Copy link
Owner

hungtcs commented Apr 17, 2021

@yindz 因为数据是来自香港天文台,所以文本部分保留了香港繁体,。实际使用中,需要繁转简的需求可以自行添加映射,后期接口或数据可能提供简体版本。
数据错误问题我会尽快修复,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants