This topic is locked
[SOLVED]

 Imprt CSV rounds number up

12/7/2020 10:20:25 AM
PHPRunner General questions
M
Mark Kramer author

I have a simple table of products :

Brand Category SKU(key) Description Warranty MSRP MAP NET


When I import the products from an excel sheet (csv format) it rounds my MSRP, MAP and NET up and drops the deicmal. The data in te MSRP, MAP, NET in the spreadsheet is in $0.00 format.
I've tried copy and paste and get the same results.
Any ideas what I'm missiong here. Running 10.4 (36153 x64) ?
View as settings are:

Edit as Text field

View as Currency

Validate as Currency

____
Thanks you.

A
acpan 12/7/2020

if values show without decimal, it could be spreadsheet formatting. You can try format the values to string in your spreadsheet before import (i.e. put a single quote in front of your values).
If still the same problem, try to echo out the values from the spreadsheet in your import event :
In Import Before Insert Event:
echo "
Raw Values From Spreadsheet => MSRP=".$rawvalues["MSRP"]." | MAP=".$rawvalues["MAP"]." | NET=" .$rawvalues["NET"];

echo "
Values Before insert to DB => MSRP=".$values["MSRP"]." | MAP=".$values["MAP"]." | NET=" .$values["NET"];
You can also manipulate the raw values before insert to DB:
// Eg: Use strval to force raw values to string

$values["MSRP"] = strval($rawvalues["MSRP"]);

M
Mark Kramer author 12/7/2020



if values show without decimal, it could be spreadsheet formatting. You can try format the values to string in your spreadsheet before import (i.e. put a single quote in front of your values).
If still the same problem, try to echo out the values from the spreadsheet in your import event :
In Import Before Insert Event:
echo "
Raw Values From Spreadsheet => MSRP=".$rawvalues["MSRP"]." | MAP=".$rawvalues["MAP"]." | NET=" .$rawvalues["NET"];

echo "
Values Before insert to DB => MSRP=".$values["MSRP"]." | MAP=".$values["MAP"]." | NET=" .$values["NET"];
You can also manipulate the raw values before insert to DB:
// Eg: Use strval to force raw values to string

$values["MSRP"] = strval($rawvalues["MSRP"]);


I will give it a try !
Thank you !

M
Mark Kramer author 12/7/2020



I will give it a try !
Thank you !


OK.... Well now. I tried the "import before event" got an error. No import.. Then magicly The colums started displaying as currency with the correct value with the old data. For all purposes it is now working... I just wish I knew what the reason was before. Nothing really changed except the echo of raw values. Maybe it re-wrote something stuck in the buffer.
Anyway Thanks for the new tricks and new way to troubleshoot the problem. I'm sure it will come in handy in the future.
Thanks again <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=93207&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />