CSV is not parsing properly. Gives 'Unquoted fields do not allow r or n '





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I'm using selenium and python to do some scrapings.
Python2.7
OS- Mac 10.14 Mojave




Error is - Unquoted fields do not allow r or n (line 2).




That means line break problem. I did this:



des = driver.find_element_by_xpath('//*[@id="descriptiontext"]/div/div/div')
.get_attribute('innerHTML')
.encode('ascii', 'ignore')
.decode('ascii')
regex=re.compile('<a.*?a>') #taking out <a> tags
des1 = str(re.findall(regex, des)[0])
des = des.replace(des1,'')

with open("new.csv", "a") as myfile:
myfilewriter = csv.writer(myfile)

if len(menuList)==2:
print (des)
type,tags=blank,blank
published='TRUE'
option1 = menuList.items()[0][0]
option1Val= menuList.items()[0][1][0].items()[0][0]
option2 = menuList.items()[1][0]
option2Val=menuList.items()[1][1][0].items()[0][0]
option3, option3Val= blank,blank
sku = directory
gram = '0'
v_inventory='shopify'
v_inventory_quantity= '100'
v_inventory_policy= 'continue'
v_fulfillment_service='manual'
try:
v_price = float(menuList.items()[1][1][0].items()[0][1]) + 10.99
except:
v_price = 10.99 + price
v_compare_price = blank
v_shipping= 'TRUE'
v_taxable= 'FALSE'
v_barcode = blank
v_imgsrc = blank
img_pos = blank
img_alt = blank
giftCard= 'FALSE'
seo_title,seo_des,gShopping,gSG,gSA,gMPN,gAd,gAdL,gSC,gCP,gSCL,gSCL1,gSCL2,gSCL3,gSCL4,v_image= blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank
v_weight_unit ='lb'
v_tax, cpi=blank,blank
myfilewriter.writerow([handle,title,des,vendor,type,tags,published,option1,option1Val,option2,option2Val,option3,option3Val,sku,gram,v_inventory,v_inventory_quantity,
v_inventory_policy,v_fulfillment_service,v_price,v_compare_price,v_shipping,v_taxable,
v_barcode,v_imgsrc,img_pos,img_alt,giftCard,seo_title,seo_des,gShopping,gSG,gSA,gMPN,gAd,gAdL,gSC,gCP,gSCL,gSCL1,gSCL2,gSCL3,gSCL4,v_image,
v_weight_unit,v_tax,cpi])


Not sure what else I can do. The output of 'des' is html of product description. So showing csv version of 'des' renders the html itself.



Please leave your email id, I'd be happy to send the csv file and scrapping code.










share|improve this question




















  • 2





    Show us the entire error message. Also, I don't see where this code uses CSV.

    – John Gordon
    Nov 23 '18 at 20:53











  • My guess is that your csv file has a r or n in it that is not in quotes. i.e. you have: col1n,col2,col3. When you should have: "col1n",col2,col3. Show us more code and show us the full error and which line the error is referring to.

    – ChrisRockGM
    Nov 23 '18 at 21:15


















0















I'm using selenium and python to do some scrapings.
Python2.7
OS- Mac 10.14 Mojave




Error is - Unquoted fields do not allow r or n (line 2).




That means line break problem. I did this:



des = driver.find_element_by_xpath('//*[@id="descriptiontext"]/div/div/div')
.get_attribute('innerHTML')
.encode('ascii', 'ignore')
.decode('ascii')
regex=re.compile('<a.*?a>') #taking out <a> tags
des1 = str(re.findall(regex, des)[0])
des = des.replace(des1,'')

with open("new.csv", "a") as myfile:
myfilewriter = csv.writer(myfile)

if len(menuList)==2:
print (des)
type,tags=blank,blank
published='TRUE'
option1 = menuList.items()[0][0]
option1Val= menuList.items()[0][1][0].items()[0][0]
option2 = menuList.items()[1][0]
option2Val=menuList.items()[1][1][0].items()[0][0]
option3, option3Val= blank,blank
sku = directory
gram = '0'
v_inventory='shopify'
v_inventory_quantity= '100'
v_inventory_policy= 'continue'
v_fulfillment_service='manual'
try:
v_price = float(menuList.items()[1][1][0].items()[0][1]) + 10.99
except:
v_price = 10.99 + price
v_compare_price = blank
v_shipping= 'TRUE'
v_taxable= 'FALSE'
v_barcode = blank
v_imgsrc = blank
img_pos = blank
img_alt = blank
giftCard= 'FALSE'
seo_title,seo_des,gShopping,gSG,gSA,gMPN,gAd,gAdL,gSC,gCP,gSCL,gSCL1,gSCL2,gSCL3,gSCL4,v_image= blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank
v_weight_unit ='lb'
v_tax, cpi=blank,blank
myfilewriter.writerow([handle,title,des,vendor,type,tags,published,option1,option1Val,option2,option2Val,option3,option3Val,sku,gram,v_inventory,v_inventory_quantity,
v_inventory_policy,v_fulfillment_service,v_price,v_compare_price,v_shipping,v_taxable,
v_barcode,v_imgsrc,img_pos,img_alt,giftCard,seo_title,seo_des,gShopping,gSG,gSA,gMPN,gAd,gAdL,gSC,gCP,gSCL,gSCL1,gSCL2,gSCL3,gSCL4,v_image,
v_weight_unit,v_tax,cpi])


Not sure what else I can do. The output of 'des' is html of product description. So showing csv version of 'des' renders the html itself.



Please leave your email id, I'd be happy to send the csv file and scrapping code.










share|improve this question




















  • 2





    Show us the entire error message. Also, I don't see where this code uses CSV.

    – John Gordon
    Nov 23 '18 at 20:53











  • My guess is that your csv file has a r or n in it that is not in quotes. i.e. you have: col1n,col2,col3. When you should have: "col1n",col2,col3. Show us more code and show us the full error and which line the error is referring to.

    – ChrisRockGM
    Nov 23 '18 at 21:15














0












0








0








I'm using selenium and python to do some scrapings.
Python2.7
OS- Mac 10.14 Mojave




Error is - Unquoted fields do not allow r or n (line 2).




That means line break problem. I did this:



des = driver.find_element_by_xpath('//*[@id="descriptiontext"]/div/div/div')
.get_attribute('innerHTML')
.encode('ascii', 'ignore')
.decode('ascii')
regex=re.compile('<a.*?a>') #taking out <a> tags
des1 = str(re.findall(regex, des)[0])
des = des.replace(des1,'')

with open("new.csv", "a") as myfile:
myfilewriter = csv.writer(myfile)

if len(menuList)==2:
print (des)
type,tags=blank,blank
published='TRUE'
option1 = menuList.items()[0][0]
option1Val= menuList.items()[0][1][0].items()[0][0]
option2 = menuList.items()[1][0]
option2Val=menuList.items()[1][1][0].items()[0][0]
option3, option3Val= blank,blank
sku = directory
gram = '0'
v_inventory='shopify'
v_inventory_quantity= '100'
v_inventory_policy= 'continue'
v_fulfillment_service='manual'
try:
v_price = float(menuList.items()[1][1][0].items()[0][1]) + 10.99
except:
v_price = 10.99 + price
v_compare_price = blank
v_shipping= 'TRUE'
v_taxable= 'FALSE'
v_barcode = blank
v_imgsrc = blank
img_pos = blank
img_alt = blank
giftCard= 'FALSE'
seo_title,seo_des,gShopping,gSG,gSA,gMPN,gAd,gAdL,gSC,gCP,gSCL,gSCL1,gSCL2,gSCL3,gSCL4,v_image= blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank
v_weight_unit ='lb'
v_tax, cpi=blank,blank
myfilewriter.writerow([handle,title,des,vendor,type,tags,published,option1,option1Val,option2,option2Val,option3,option3Val,sku,gram,v_inventory,v_inventory_quantity,
v_inventory_policy,v_fulfillment_service,v_price,v_compare_price,v_shipping,v_taxable,
v_barcode,v_imgsrc,img_pos,img_alt,giftCard,seo_title,seo_des,gShopping,gSG,gSA,gMPN,gAd,gAdL,gSC,gCP,gSCL,gSCL1,gSCL2,gSCL3,gSCL4,v_image,
v_weight_unit,v_tax,cpi])


Not sure what else I can do. The output of 'des' is html of product description. So showing csv version of 'des' renders the html itself.



Please leave your email id, I'd be happy to send the csv file and scrapping code.










share|improve this question
















I'm using selenium and python to do some scrapings.
Python2.7
OS- Mac 10.14 Mojave




Error is - Unquoted fields do not allow r or n (line 2).




That means line break problem. I did this:



des = driver.find_element_by_xpath('//*[@id="descriptiontext"]/div/div/div')
.get_attribute('innerHTML')
.encode('ascii', 'ignore')
.decode('ascii')
regex=re.compile('<a.*?a>') #taking out <a> tags
des1 = str(re.findall(regex, des)[0])
des = des.replace(des1,'')

with open("new.csv", "a") as myfile:
myfilewriter = csv.writer(myfile)

if len(menuList)==2:
print (des)
type,tags=blank,blank
published='TRUE'
option1 = menuList.items()[0][0]
option1Val= menuList.items()[0][1][0].items()[0][0]
option2 = menuList.items()[1][0]
option2Val=menuList.items()[1][1][0].items()[0][0]
option3, option3Val= blank,blank
sku = directory
gram = '0'
v_inventory='shopify'
v_inventory_quantity= '100'
v_inventory_policy= 'continue'
v_fulfillment_service='manual'
try:
v_price = float(menuList.items()[1][1][0].items()[0][1]) + 10.99
except:
v_price = 10.99 + price
v_compare_price = blank
v_shipping= 'TRUE'
v_taxable= 'FALSE'
v_barcode = blank
v_imgsrc = blank
img_pos = blank
img_alt = blank
giftCard= 'FALSE'
seo_title,seo_des,gShopping,gSG,gSA,gMPN,gAd,gAdL,gSC,gCP,gSCL,gSCL1,gSCL2,gSCL3,gSCL4,v_image= blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank,blank
v_weight_unit ='lb'
v_tax, cpi=blank,blank
myfilewriter.writerow([handle,title,des,vendor,type,tags,published,option1,option1Val,option2,option2Val,option3,option3Val,sku,gram,v_inventory,v_inventory_quantity,
v_inventory_policy,v_fulfillment_service,v_price,v_compare_price,v_shipping,v_taxable,
v_barcode,v_imgsrc,img_pos,img_alt,giftCard,seo_title,seo_des,gShopping,gSG,gSA,gMPN,gAd,gAdL,gSC,gCP,gSCL,gSCL1,gSCL2,gSCL3,gSCL4,v_image,
v_weight_unit,v_tax,cpi])


Not sure what else I can do. The output of 'des' is html of product description. So showing csv version of 'des' renders the html itself.



Please leave your email id, I'd be happy to send the csv file and scrapping code.







python python-2.7 selenium selenium-webdriver






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 21:51







smithites125

















asked Nov 23 '18 at 20:48









smithites125smithites125

11




11








  • 2





    Show us the entire error message. Also, I don't see where this code uses CSV.

    – John Gordon
    Nov 23 '18 at 20:53











  • My guess is that your csv file has a r or n in it that is not in quotes. i.e. you have: col1n,col2,col3. When you should have: "col1n",col2,col3. Show us more code and show us the full error and which line the error is referring to.

    – ChrisRockGM
    Nov 23 '18 at 21:15














  • 2





    Show us the entire error message. Also, I don't see where this code uses CSV.

    – John Gordon
    Nov 23 '18 at 20:53











  • My guess is that your csv file has a r or n in it that is not in quotes. i.e. you have: col1n,col2,col3. When you should have: "col1n",col2,col3. Show us more code and show us the full error and which line the error is referring to.

    – ChrisRockGM
    Nov 23 '18 at 21:15








2




2





Show us the entire error message. Also, I don't see where this code uses CSV.

– John Gordon
Nov 23 '18 at 20:53





Show us the entire error message. Also, I don't see where this code uses CSV.

– John Gordon
Nov 23 '18 at 20:53













My guess is that your csv file has a r or n in it that is not in quotes. i.e. you have: col1n,col2,col3. When you should have: "col1n",col2,col3. Show us more code and show us the full error and which line the error is referring to.

– ChrisRockGM
Nov 23 '18 at 21:15





My guess is that your csv file has a r or n in it that is not in quotes. i.e. you have: col1n,col2,col3. When you should have: "col1n",col2,col3. Show us more code and show us the full error and which line the error is referring to.

– ChrisRockGM
Nov 23 '18 at 21:15












1 Answer
1






active

oldest

votes


















0














Update::
Oh my god! Literally, wasted 2 days on this. Issue was because of the Mac. When used Windows Comma Seperated Values (.csv), it works!....Insane... can anybody enlighten me, what the difference is?






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452783%2fcsv-is-not-parsing-properly-gives-unquoted-fields-do-not-allow-r-or-n%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Update::
    Oh my god! Literally, wasted 2 days on this. Issue was because of the Mac. When used Windows Comma Seperated Values (.csv), it works!....Insane... can anybody enlighten me, what the difference is?






    share|improve this answer




























      0














      Update::
      Oh my god! Literally, wasted 2 days on this. Issue was because of the Mac. When used Windows Comma Seperated Values (.csv), it works!....Insane... can anybody enlighten me, what the difference is?






      share|improve this answer


























        0












        0








        0







        Update::
        Oh my god! Literally, wasted 2 days on this. Issue was because of the Mac. When used Windows Comma Seperated Values (.csv), it works!....Insane... can anybody enlighten me, what the difference is?






        share|improve this answer













        Update::
        Oh my god! Literally, wasted 2 days on this. Issue was because of the Mac. When used Windows Comma Seperated Values (.csv), it works!....Insane... can anybody enlighten me, what the difference is?







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 '18 at 23:12









        smithites125smithites125

        11




        11
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452783%2fcsv-is-not-parsing-properly-gives-unquoted-fields-do-not-allow-r-or-n%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()