我有mongo集合,在每个文档中都有问题和答案。对于某些集合,有多个问题的答案。
如果对于所有文件,如果每个问题都有单个答案,我可以使用
将问题答案输出到csvmongoexport --db curiabot --collection justiaqa --type csv --fields question,answer --out justia.csv
但由于没有多个答案,范围从1-10,我很困惑如何为QA创建csv。我只想导出问题和答案。
这是一个有5个答案的样本
{'answer-0': u"Hi All,Me and my wife from Sri Lanka and we came to the USA with our Green cards about a year ago. After we received our Green card Visa, we could get our Divorce decision from Sri Lankan courts, then we came USA as divorced couple in Sri Lanka separetly. Now She\u2019s in CA and I'm in MD and we lives as singles. To USA government, we are still married because we didn\u2019t inform US authorities about we have got our divorce (papers issued with late). As we received our Sri Lankan court documents recently, now we can inform about that.So my questions are1. Do we have to file a divorce case in the US again?2. If not, to where should we provide those Sri Lankan court decision documents?3. Will this case effect to our Green Cards?4. What kind of things will occur if we both want to marry again(separately)I hope somebody might be in here would have any knowledge about this area will be able to give some advices.\xa0Even rough and logical possibilities , predictions\xa0are also appreciate.Thanks in advance.PkChari 0",
'answer-1': u'You should be working with an immigration attorney. On what basis were you granted green cards? If one was granted based on being married to someone who qualified, that person may no longer be eligible. https://www.uscis.gov/green-card/after-green-card-granted/conditional-permanent-residence/remove-conditions-permanent-residence-based-marriage\xa0\xa0A green card is not a visa. Do you have an actual green car or just a visa? If a visa, what visa do you each hold?\xa0If you divorced in Sri Lanka, you are divorced period. You do need to file your change of status in the US. Not doing so if fraud and can cause you both to lose legal status.\xa0 0',
'answer-2': u'I won the green card from the Diversity Lottery program https://www.dvlottery.state.gov. Im having DV1 visa and she was my spouse she got DV2 visa both have green card now. but before we left Sri Lanka we got our divorce finalized. 0',
'answer-3': u'You REALLY need to speak with an immigration attorney. Stat. 0',
'answer-4': u'If your ex-wife (and she is your ex-wife) got the immigrant visa on the basis that she was married to you. and you were actually divorced when you entered the US, you may both be in trouble. \xa0She because she was no longer the wife of a visa holder and you because you did not disclose you were no longer married. Therefore it is highly suggested you both contact an immigration lawyer now. 0',
'answer-5': u'Thanks all. Ill speek to immigration lawyer ASAP.\xa0\xa0When we apply for the visa, when we receive our visa we were married. After that we got divorced thats why Im having doubt that our divorce might not effect to our visa.\xa0Anyway thanks all. I appreciate your help. 0',
'desc_link': 'http://boards.answers.findlaw.com/topic/240308-green-card-holders-having-divorce-papers-from-country-of-their-marriage-was/',
'parent_link': 'http://boards.answers.findlaw.com/forum/188-immigration/?page=585',
'question': u'Green Card holders having divorce papers from country of their marriage was'}
这是三个答案
{'answer-0': u'I am a US citizen and I live in Brazil. I have 2 kid that were born here in Brazil.\xa0 I want to move to the States soon, what kind of visa my kids need? My husband is brasilian....Tks... 0',
'answer-1': u'If you are a citizen, your children likely are as well. https://www.uscis.gov/us-citizenship/citizenship-through-parents 0',
'answer-2': u"You have to go to the nearest US Embassy/Consular office with proof of your identity and citizenship and the children's birth certificates to obtain US passports for them to travel to the US. 0",
'desc_link': 'http://boards.answers.findlaw.com/topic/240576-us-citizen-living-abroad/',
'parent_link': 'http://boards.answers.findlaw.com/forum/188-immigration/?page=585',
'question': u'US citizen living abroad'}
在CSV中,对于每一行,应该有第一列有问题,在休息列中有答案。
有没有办法像这样出口?
我也在使用python,如果有办法使用python我可以做。