How to append something to a new line in a excel file?












0















Hey I am using easygui and appending the user input to a excel (csv file). However the userinput will continuously append to the same line, and not the next line.
Here is my code :



   #Adding a User

msg = 'Adding your information'
title = 'Uk Users'
box_names = ["Email" , "Password"]
box_values = (easygui.multpasswordbox(msg, title, box_names,))


while box_values[0] == '' or box_values[1] == '':
msg = 'Try again'
title = 'you missed a box, please try again!'
box_names_1 = ["Email" , "Password"]
box_values = str(easygui.multpasswordbox(msg, title, box_names_1))
#How to make it repeat?
else:
for i in range(len(box_values)):
box_values = str(box_values)
f = open('USERS.csv' , 'a') #'a' is for appending
f.write(box_values) #How to add something to a new line?









share|improve this question























  • You could use the csv library from python and use the writerow method there.

    – toti08
    Nov 19 '18 at 14:42











  • Duplicate of How do you append to a file??

    – bene
    Nov 19 '18 at 14:43
















0















Hey I am using easygui and appending the user input to a excel (csv file). However the userinput will continuously append to the same line, and not the next line.
Here is my code :



   #Adding a User

msg = 'Adding your information'
title = 'Uk Users'
box_names = ["Email" , "Password"]
box_values = (easygui.multpasswordbox(msg, title, box_names,))


while box_values[0] == '' or box_values[1] == '':
msg = 'Try again'
title = 'you missed a box, please try again!'
box_names_1 = ["Email" , "Password"]
box_values = str(easygui.multpasswordbox(msg, title, box_names_1))
#How to make it repeat?
else:
for i in range(len(box_values)):
box_values = str(box_values)
f = open('USERS.csv' , 'a') #'a' is for appending
f.write(box_values) #How to add something to a new line?









share|improve this question























  • You could use the csv library from python and use the writerow method there.

    – toti08
    Nov 19 '18 at 14:42











  • Duplicate of How do you append to a file??

    – bene
    Nov 19 '18 at 14:43














0












0








0








Hey I am using easygui and appending the user input to a excel (csv file). However the userinput will continuously append to the same line, and not the next line.
Here is my code :



   #Adding a User

msg = 'Adding your information'
title = 'Uk Users'
box_names = ["Email" , "Password"]
box_values = (easygui.multpasswordbox(msg, title, box_names,))


while box_values[0] == '' or box_values[1] == '':
msg = 'Try again'
title = 'you missed a box, please try again!'
box_names_1 = ["Email" , "Password"]
box_values = str(easygui.multpasswordbox(msg, title, box_names_1))
#How to make it repeat?
else:
for i in range(len(box_values)):
box_values = str(box_values)
f = open('USERS.csv' , 'a') #'a' is for appending
f.write(box_values) #How to add something to a new line?









share|improve this question














Hey I am using easygui and appending the user input to a excel (csv file). However the userinput will continuously append to the same line, and not the next line.
Here is my code :



   #Adding a User

msg = 'Adding your information'
title = 'Uk Users'
box_names = ["Email" , "Password"]
box_values = (easygui.multpasswordbox(msg, title, box_names,))


while box_values[0] == '' or box_values[1] == '':
msg = 'Try again'
title = 'you missed a box, please try again!'
box_names_1 = ["Email" , "Password"]
box_values = str(easygui.multpasswordbox(msg, title, box_names_1))
#How to make it repeat?
else:
for i in range(len(box_values)):
box_values = str(box_values)
f = open('USERS.csv' , 'a') #'a' is for appending
f.write(box_values) #How to add something to a new line?






python file append






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 '18 at 14:35









Beni billhardtBeni billhardt

31




31













  • You could use the csv library from python and use the writerow method there.

    – toti08
    Nov 19 '18 at 14:42











  • Duplicate of How do you append to a file??

    – bene
    Nov 19 '18 at 14:43



















  • You could use the csv library from python and use the writerow method there.

    – toti08
    Nov 19 '18 at 14:42











  • Duplicate of How do you append to a file??

    – bene
    Nov 19 '18 at 14:43

















You could use the csv library from python and use the writerow method there.

– toti08
Nov 19 '18 at 14:42





You could use the csv library from python and use the writerow method there.

– toti08
Nov 19 '18 at 14:42













Duplicate of How do you append to a file??

– bene
Nov 19 '18 at 14:43





Duplicate of How do you append to a file??

– bene
Nov 19 '18 at 14:43












1 Answer
1






active

oldest

votes


















0














You could use the csv library, defining a Writer object to write to your file. So you would need to replace the else statement with something like that:



else:
with open('USERS.csv', 'a', newline = '') as csvFile:
csvWriter = csv.writer(csvFile, delimiter = ',')
csvWriter.writerow(box_values)


The writerow method will automatically put your new data into a new row. Also you don't need to explicitly convert your data to string.






share|improve this answer


























  • Thanks, that does work although it does skip a line in the excel file, it is a lot better than what I had before.

    – Beni billhardt
    Nov 20 '18 at 2:16











  • @Benibillhardt right. Then in order to address that problem you should open the file specifying the parameter newline=''. I'll update my answer.

    – toti08
    Nov 20 '18 at 7:19













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%2f53376874%2fhow-to-append-something-to-a-new-line-in-a-excel-file%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














You could use the csv library, defining a Writer object to write to your file. So you would need to replace the else statement with something like that:



else:
with open('USERS.csv', 'a', newline = '') as csvFile:
csvWriter = csv.writer(csvFile, delimiter = ',')
csvWriter.writerow(box_values)


The writerow method will automatically put your new data into a new row. Also you don't need to explicitly convert your data to string.






share|improve this answer


























  • Thanks, that does work although it does skip a line in the excel file, it is a lot better than what I had before.

    – Beni billhardt
    Nov 20 '18 at 2:16











  • @Benibillhardt right. Then in order to address that problem you should open the file specifying the parameter newline=''. I'll update my answer.

    – toti08
    Nov 20 '18 at 7:19


















0














You could use the csv library, defining a Writer object to write to your file. So you would need to replace the else statement with something like that:



else:
with open('USERS.csv', 'a', newline = '') as csvFile:
csvWriter = csv.writer(csvFile, delimiter = ',')
csvWriter.writerow(box_values)


The writerow method will automatically put your new data into a new row. Also you don't need to explicitly convert your data to string.






share|improve this answer


























  • Thanks, that does work although it does skip a line in the excel file, it is a lot better than what I had before.

    – Beni billhardt
    Nov 20 '18 at 2:16











  • @Benibillhardt right. Then in order to address that problem you should open the file specifying the parameter newline=''. I'll update my answer.

    – toti08
    Nov 20 '18 at 7:19
















0












0








0







You could use the csv library, defining a Writer object to write to your file. So you would need to replace the else statement with something like that:



else:
with open('USERS.csv', 'a', newline = '') as csvFile:
csvWriter = csv.writer(csvFile, delimiter = ',')
csvWriter.writerow(box_values)


The writerow method will automatically put your new data into a new row. Also you don't need to explicitly convert your data to string.






share|improve this answer















You could use the csv library, defining a Writer object to write to your file. So you would need to replace the else statement with something like that:



else:
with open('USERS.csv', 'a', newline = '') as csvFile:
csvWriter = csv.writer(csvFile, delimiter = ',')
csvWriter.writerow(box_values)


The writerow method will automatically put your new data into a new row. Also you don't need to explicitly convert your data to string.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 '18 at 7:20

























answered Nov 19 '18 at 14:52









toti08toti08

1,77941623




1,77941623













  • Thanks, that does work although it does skip a line in the excel file, it is a lot better than what I had before.

    – Beni billhardt
    Nov 20 '18 at 2:16











  • @Benibillhardt right. Then in order to address that problem you should open the file specifying the parameter newline=''. I'll update my answer.

    – toti08
    Nov 20 '18 at 7:19





















  • Thanks, that does work although it does skip a line in the excel file, it is a lot better than what I had before.

    – Beni billhardt
    Nov 20 '18 at 2:16











  • @Benibillhardt right. Then in order to address that problem you should open the file specifying the parameter newline=''. I'll update my answer.

    – toti08
    Nov 20 '18 at 7:19



















Thanks, that does work although it does skip a line in the excel file, it is a lot better than what I had before.

– Beni billhardt
Nov 20 '18 at 2:16





Thanks, that does work although it does skip a line in the excel file, it is a lot better than what I had before.

– Beni billhardt
Nov 20 '18 at 2:16













@Benibillhardt right. Then in order to address that problem you should open the file specifying the parameter newline=''. I'll update my answer.

– toti08
Nov 20 '18 at 7:19







@Benibillhardt right. Then in order to address that problem you should open the file specifying the parameter newline=''. I'll update my answer.

– toti08
Nov 20 '18 at 7:19






















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%2f53376874%2fhow-to-append-something-to-a-new-line-in-a-excel-file%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()