0
api
에서 가사를 긁어내어 csv
파일로 저장하고 있습니다.파이썬 - CSV 파일에서 구분 기호 설정
이 내가 그것을하고 있어요 방법은 다음과 같습니다
with codecs.open('lyrics.csv', 'ab', encoding='utf8') as outputfile:
outwriter = csv.writer(outputfile)
for url in urls:
page_url = base_url + url
page = requests.get(page_url, headers=headers)
html = BeautifulSoup(page.text, "html.parser")
lyrics = html.find('div', class_='lyrics').get_text()
outwriter.writerow(lyrics)
이 지금은 예를 들어,
0
처럼, 이진 값으로, 행에 각각의 가사를 저장하는 방법을 알아 내려고 노력하고있어. 그래서 같은
각 가사 인쇄 :
[Hook: John Mayer]
Bittersweet
You're gonna be the death of me
I don't want you, but I need you
I love you and hate you at the very same time
Bittersweet
[Verse 1: Kanye West]
See, what I want so much should never hurt this bad
Never did this before, that's what the virgin says
We've been generally warned, that's what the surgeon says
God, talk to me now, this is an emergency
And she claims she only with me for the currency
You cut me deep, bitch, cut me like surgery
And I was too proud to admit that it was hurting me
I'd never do that to you, at least purposely
We breaking up again, we making up again
But we don't love no more, I guess we fucking then
Have you ever felt you ever want to kill her?
And you mix them emotions with tequila
And you mix that with a little bad advice
On one of them bad nights, y'all have a bad fight
And you talk about her family, her aunts and shit
And she say, "Motherfucker, your momma's a bitch"
You know, domestic drama and shit, all the attitude
I'd never hit a girl, but I'll shake the shit out of you
But I'mma be the bigger man, big pimpin' like Jigga man
Oh, I guess I figure it's
[Hook: John Mayer]
Bittersweet
You're gonna be the death of me
I don't want you, but I need you
I love you, hate you at the very same time
Bittersweet
[Verse 2: Kanye West]
See, what I want so much should never hurt this bad
Never did this before, that's what the virgin says
We've been generally warned, that's what the surgeon says
God, talk to me now, this is an emergency
And my niggas said I shouldn't let it worry me
I need to focus on the girls we getting currently
But I been thinking and it got me back to sinking
And this relationship, it even got me back to drinking
Now this Hennessy, uh, it's gonna be the death of me
And I always thought that you having my child was our destiny
But I can't even vibe with you sexually
'Cause every time that I'd try, you would question me
Saying, "You fucking them girls, disrespecting me
You don't see how your lies is affecting me?
You don't see how our life was supposed to be?
And I never let a nigga get that close to me
And you ain't cracked up to what you were supposed to be
You always gone, you always be where them hoes will be"
And this the first time she ever spilled her soul to me
[Hook: John Mayer & Kanye West]
Bittersweet (I fucked up and I know it, G)
You're gonna be the death of me (I guess it's bittersweet poetry)
I don't want you, but I need you
I love you and hate you at the very same time
Bittersweet
You're gonna be the death of me
I don't want you, but I need you
I love you and hate you at the very same time
[Verse 3: Kanye West]
See, what I want so much should never hurt this bad
Never did this before, that's what the virgin says
We've been generally warned, that's what the surgeon says
God, talk to me now, this is an emergency
See, what I want so much should never hurt this bad
Never did this before, that's what the virgin says
We've been generally warned, that's what the surgeon says
God, talk to me now, this is an emergency
[Hook: John Mayer]
Bittersweet
You're gonna be the death of me
I don't want you, but I need you
I love you and hate you at the very same time
(Bittersweet
You're gonna be the death of me
I don't want you
...very same time)
어떻게 값 0
에 쉼표 (,)로 구분 한 행의 전체 가사를하기 위해 구분 기호를 설정합니까?
with codecs.open('classification/data/genius.csv', 'ab', encoding='utf8') as outputfile:
outwriter = csv.DictWriter(outputfile, fieldnames = ['lyrics', 'classification'])
writer.writeheader()
for url in urls:
page_url = base_url + url
page = requests.get(page_url, headers=headers)
html = BeautifulSoup(page.text, "html.parser")
lyrics = html.find('div', class_='lyrics').get_text()
outwriter.writerow({'lyrics':lyrics, 'classification':0})
: