Importing CSV product data - updating price column












0















I’ve searched but can’t find exactly what I’m trying to do, or just losing my mind... probably both.



I’ve got a data feed, with the following fields: Product ID, Name, Retail Price, Sales Price. Right now I dump this into a Google Sheets file via scripts, trim the necessary fields, export via CSV and back in MySQL but I need the data to go right from the feed CSV URL to MySQL, and correct a few fields.



For some reason, some of the prices have weird values, such as 4728.7376 while others have 282. I’d like to basically trim andything past the decimal point. When I tried that, I have some rows that don’t have any prices (it’s annoying) and seems to break the import.



Any suggestions on simplifying this to pull from the URL feed, fix issues and import into MySQL — which is through Google Cloud, but currently testing using MAMP. I can only get it to work importing using varchar(100) and need to do calculations with those columns; as long as the value is present.



Thanks in advance!










share|improve this question























  • If you are using load data infile you can push the columns from a csv file to variables and manipulate them please read dev.mysql.com/doc/refman/8.0/en/load-data.html. It might help if you added some sample rows from the csv file as text to the question.

    – P.Salmon
    Nov 21 '18 at 11:45











  • Thanks! I’ll add some of the same code and data here shortly

    – John
    Nov 21 '18 at 12:08
















0















I’ve searched but can’t find exactly what I’m trying to do, or just losing my mind... probably both.



I’ve got a data feed, with the following fields: Product ID, Name, Retail Price, Sales Price. Right now I dump this into a Google Sheets file via scripts, trim the necessary fields, export via CSV and back in MySQL but I need the data to go right from the feed CSV URL to MySQL, and correct a few fields.



For some reason, some of the prices have weird values, such as 4728.7376 while others have 282. I’d like to basically trim andything past the decimal point. When I tried that, I have some rows that don’t have any prices (it’s annoying) and seems to break the import.



Any suggestions on simplifying this to pull from the URL feed, fix issues and import into MySQL — which is through Google Cloud, but currently testing using MAMP. I can only get it to work importing using varchar(100) and need to do calculations with those columns; as long as the value is present.



Thanks in advance!










share|improve this question























  • If you are using load data infile you can push the columns from a csv file to variables and manipulate them please read dev.mysql.com/doc/refman/8.0/en/load-data.html. It might help if you added some sample rows from the csv file as text to the question.

    – P.Salmon
    Nov 21 '18 at 11:45











  • Thanks! I’ll add some of the same code and data here shortly

    – John
    Nov 21 '18 at 12:08














0












0








0








I’ve searched but can’t find exactly what I’m trying to do, or just losing my mind... probably both.



I’ve got a data feed, with the following fields: Product ID, Name, Retail Price, Sales Price. Right now I dump this into a Google Sheets file via scripts, trim the necessary fields, export via CSV and back in MySQL but I need the data to go right from the feed CSV URL to MySQL, and correct a few fields.



For some reason, some of the prices have weird values, such as 4728.7376 while others have 282. I’d like to basically trim andything past the decimal point. When I tried that, I have some rows that don’t have any prices (it’s annoying) and seems to break the import.



Any suggestions on simplifying this to pull from the URL feed, fix issues and import into MySQL — which is through Google Cloud, but currently testing using MAMP. I can only get it to work importing using varchar(100) and need to do calculations with those columns; as long as the value is present.



Thanks in advance!










share|improve this question














I’ve searched but can’t find exactly what I’m trying to do, or just losing my mind... probably both.



I’ve got a data feed, with the following fields: Product ID, Name, Retail Price, Sales Price. Right now I dump this into a Google Sheets file via scripts, trim the necessary fields, export via CSV and back in MySQL but I need the data to go right from the feed CSV URL to MySQL, and correct a few fields.



For some reason, some of the prices have weird values, such as 4728.7376 while others have 282. I’d like to basically trim andything past the decimal point. When I tried that, I have some rows that don’t have any prices (it’s annoying) and seems to break the import.



Any suggestions on simplifying this to pull from the URL feed, fix issues and import into MySQL — which is through Google Cloud, but currently testing using MAMP. I can only get it to work importing using varchar(100) and need to do calculations with those columns; as long as the value is present.



Thanks in advance!







mysql csv






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 11:37









JohnJohn

11




11













  • If you are using load data infile you can push the columns from a csv file to variables and manipulate them please read dev.mysql.com/doc/refman/8.0/en/load-data.html. It might help if you added some sample rows from the csv file as text to the question.

    – P.Salmon
    Nov 21 '18 at 11:45











  • Thanks! I’ll add some of the same code and data here shortly

    – John
    Nov 21 '18 at 12:08



















  • If you are using load data infile you can push the columns from a csv file to variables and manipulate them please read dev.mysql.com/doc/refman/8.0/en/load-data.html. It might help if you added some sample rows from the csv file as text to the question.

    – P.Salmon
    Nov 21 '18 at 11:45











  • Thanks! I’ll add some of the same code and data here shortly

    – John
    Nov 21 '18 at 12:08

















If you are using load data infile you can push the columns from a csv file to variables and manipulate them please read dev.mysql.com/doc/refman/8.0/en/load-data.html. It might help if you added some sample rows from the csv file as text to the question.

– P.Salmon
Nov 21 '18 at 11:45





If you are using load data infile you can push the columns from a csv file to variables and manipulate them please read dev.mysql.com/doc/refman/8.0/en/load-data.html. It might help if you added some sample rows from the csv file as text to the question.

– P.Salmon
Nov 21 '18 at 11:45













Thanks! I’ll add some of the same code and data here shortly

– John
Nov 21 '18 at 12:08





Thanks! I’ll add some of the same code and data here shortly

– John
Nov 21 '18 at 12:08












0






active

oldest

votes











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%2f53411242%2fimporting-csv-product-data-updating-price-column%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















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%2f53411242%2fimporting-csv-product-data-updating-price-column%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







Popular posts from this blog

'app-layout' is not a known element: how to share Component with different Modules

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

WPF add header to Image with URL pettitions [duplicate]