problem solved.
while getting info from csv file I limited myself with 1000 charcters:
$data = fgetcsv($handle, 1000);
:)
afan@xxxxxxxx wrote:
My marketing department create a csv file which later upload into
database. Everything was working fine - until upload they tried to
make two days ago. In that file there were few of products that drive
me crazy. The file is here: http://www.afan.net/7V_2005.csv The file
has just "troublemakers".
When you look at them with excel or any text editor - it looks just
fine. Can't see anything wrong.
But, when you display them using print_r() or foreach() or while()
functions the products will be splitted into 2 arrays:
This is product 07V0120 (index 0):
Array ( [0] => 07V0120 [1] => Ultra Cotton Heavyweight Tee [2] => 6.1
ounce, 100% cotton pre-shrunk jersey. Comfortable European cut with
double-needle topstitched neckline, double stitched sleeve and waist
hems. Seamless collar with taped neck & shoulders. Sizes S-2X. 3X, 4X
and 5X in select colors. [3] => Neutrals - **White, *Natural |
Heathers - **Ash, **Sport Grey | Colors - Leaf, Eggplant, *Stone Blue,
*Cardinal Red, Lime, *Kelly Green, Vegas Gold, Lt Pink, Ice Grey,
*Gold, *Texas Orange, Sapphire, Jade Dome, **Navy, *Forest Green,
Steel, **Black, *Orange, *Sand, Olive, **Red, *Charcoal, **Royal,
Pine, *Prairie Dust, *Lt Blue, Azalea, *Blue Dusk, *Indigo Blue,
*Purple, *Maroon, Chestnut, Violet, *Daisy | Color/ Size key:
*available up to 3X, **available up to 5X [4] => Price includes
1-color screened imprint. Screen charge, add $24.00(g) per color, per
location. Additional imprint colors add $.42(c) per color per
location. Add $1.33(c) per 2X - 5X. [5] => 12 [6] => 24 [7] => 48 [8]
=> 72 [9] => 144 [10] => Screened - neutrals [11] => 5.29 [12] => 5.2
[13] => 5.15 [14] => 5.11 [15] => 3.69 [16] => [17] => [18] => [19] =>
[20] => [21] => [22] => Screened - heathers [23] => 5.89 [24] => 5.79
[25] => 5.73 [26] => 5.68 [27] => 4.26 [28] => [29] => [30] => [31] =>
[32] => [33] => [34] => Screened - colors [35] => 6.49 [36] => 6.37
[37] => 6.32 [38] => 6.26 [39] => 4.82 [40] => [41] => [42] => [43] =>
[44] => [45] => [46] => 5c [47] => [48] => 5c [49] => [50] => 5c [51]
=> [52] => 46, [53] => [54] => [55] => [56] => [57] => [58] => 3 [59]
=> 15 [60] => 2006 )
Array has alway 61 element. Index 0 is product ser. number and always
start with '07V0' and last element, index 60, is alway '2006'.
But, when I list it using print_r() function I'll get this:
Array ( [0] => 07V0120 [1] => Ultra Cotton Heavyweight Tee [2] => 6.1
ounce, 100% cotton pre-shrunk jersey. Comfortable European cut with
double-needle topstitched neckline, double stitched sleeve and waist
hems. Seamless collar with taped neck & shoulders. Sizes S-2X. 3X, 4X
and 5X in select colors. [3] => Neutrals - **White, *Natural |
Heathers - **Ash, **Sport Grey | Colors - Leaf, Eggplant, *Stone Blue,
*Cardinal Red, Lime, *Kelly Green, Vegas Gold, Lt Pink, Ice Grey,
*Gold, *Texas Orange, Sapphire, Jade Dome, **Navy, *Forest Green,
Steel, **Black, *Orange, *Sand, Olive, **Red, *Charcoal, **Royal,
Pine, *Prairie Dust, *Lt Blue, Azalea, *Blue Dusk, *Indigo Blue,
*Purple, *Maroon, Chestnut, Violet, *Daisy | Color/ Size key:
*available up to 3X, **available up to 5X [4] => Price includes
1-color screened imprint. Screen charge, add $24.00(g) per color, per
location. Additional imprint colors add $.42(c) per color per
location. Add $1.33(c) per 2X - 5X. [5] => 12 [6] => 24 [7] => 48 [8]
=> 72 [9] => 144 [10] => Screened - neutrals [11] => 5.29 [12] => 5.2
[13] => 5.15 [14] => 5.11 [15] => 3.69 [16] => [17] => [18] => [19] =>
[20] => [21] => [22] => S )
------------------------------------------------------------------------
Array ( [0] => creened - heathers [1] => 5.89 [2] => 5.79 [3] => 5.73
[4] => 5.68 [5] => 4.26 [6] => [7] => [8] => [9] => [10] => [11] =>
[12] => Screened - colors [13] => 6.49 [14] => 6.37 [15] => 6.32 [16]
=> 6.26 [17] => 4.82 [18] => [19] => [20] => [21] => [22] => [23] =>
[24] => 5c [25] => [26] => 5c [27] => [28] => 5c [29] => [30] => 46,
[31] => [32] => [33] => [34] => [35] => [36] => 3 [37] => 15 [38] =>
2006 )
The array is splitted into 2 arrays. As you ca see, this one is
splitted right in the middle of the content S*|*creened - heathers.
And, when I try to upload this into database I'll get error because
code's trying to insert 'creened - heathers' fro 2nd array as product
ser. number.
But, funny thing is it looks like it cut right after certain number of
characters of WHOLE ROW? As far as I was able to calculate, it breaks
between 951st and 993rd character.?
Also, if I delete certain number of characters from first array - same
number of characters will be pulled from 2nd to 1st array. If I delete
e.g., "neutrals" (8 characters) from [10] =>Screened - neutrals from
1st array, first 8 characters from 2nd array, "creened ", from [0] =>
creened - heathers, will be moved to 1st array, and the array will
look now:
Array ( [0] => 07V0120 [1] => Ultra Cotton Heavyweight Tee [2] => 6.1
ounce, 100% cotton pre-shrunk jersey. Comfortable European cut with
double-needle topstitched neckline, double stitched sleeve and waist
hems. Seamless collar with taped neck & shoulders. Sizes S-2X. 3X, 4X
and 5X in select colors. [3] => Neutrals - **White, *Natural |
Heathers - **Ash, **Sport Grey | Colors - Leaf, Eggplant, *Stone Blue,
*Cardinal Red, Lime, *Kelly Green, Vegas Gold, Lt Pink, Ice Grey,
*Gold, *Texas Orange, Sapphire, Jade Dome, **Navy, *Forest Green,
Steel, **Black, *Orange, *Sand, Olive, **Red, *Charcoal, **Royal,
Pine, *Prairie Dust, *Lt Blue, Azalea, *Blue Dusk, *Indigo Blue,
*Purple, *Maroon, Chestnut, Violet, *Daisy | Color/ Size key:
*available up to 3X, **available up to 5X [4] => Price includes
1-color screened imprint. Screen charge, add $24.00(g) per color, per
location. Additional imprint colors add $.42(c) per color per
location. Add $1.33(c) per 2X - 5X. [5] => 12 [6] => 24 [7] => 48 [8]
=> 72 [9] => 144 [10] => Screened - neutrals [11] => 5.29 [12] => 5.2
[13] => 5.15 [14] => 5.11 [15] => 3.69 [16] => [17] => [18] => [19] =>
[20] => [21] => [22] => Screened )
------------------------------------------------------------------------
Array ( [0] => - heathers [1] => 5.89 [2] => 5.79 [3] => 5.73 [4] =>
5.68 [5] => 4.26 [6] => [7] => [8] => [9] => [10] => [11] => [12] =>
Screened - colors [13] => 6.49 [14] => 6.37 [15] => 6.32 [16] => 6.26
[17] => 4.82 [18] => [19] => [20] => [21] => [22] => [23] => [24] =>
5c [25] => [26] => 5c [27] => [28] => 5c [29] => [30] => 46, [31] =>
[32] => [33] => [34] => [35] => [36] => 3 [37] => 15 [38] => 2006 )
Any ideas what's going on???
I tried to explain as better as I can, but you can laugh to my English :)
-afan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php