ClickAndMortar / AdvancedCsvConnectorBundle

Advanced CSV Connector Bundle for Akeneo
https://www.clickandmortar.fr/blog/akeneo-csv-advanced-connector
22 stars 5 forks source link

CSV files with embedded line returns wont import properly #42

Open dankoz51 opened 3 years ago

dankoz51 commented 3 years ago

This csv file will not import as it will break on the returns that are part of the HTML fields. This file will import and export out of google sheets just fine but when it goes into akeneo advanced csv it will break it apart based on the embed \n returns.

It should be able to process /n that is encapsulated such as " some text \n some text \n"

"sku","attribute_set","type","store","configurable_attributes","size_color","name","short_description","description","price","qty","is_in_stock","manage_stock","use_config_manage_stock","status","visibility","weight","categories","thumbnail","small_image","image","media_gallery","special_price","special_from_date","special_to_date","age_grade","condition","era","series","manufacturer","brand","product_type","material","scale","product_available","meta_keyword","fet_tax","tier_price:dealer1","tier_price:dealer2"
"AL 25854","Default","simple","admin","","","LOAD CONTROLLER SINGLE HEAVY DUTY COMPESSOR SYSTEM - AIR LIFT","<p><span style=""font-family: Calibri;"">LoadController Single On Board Air Compressor System is the quick and convenient way to inflate and deflate your vehicle&rsquo;s air springs while on the go. The last place you probably want to drive your loaded vehicle and trailer is into a tiny gas station to fill up your air springs. With a LoadController Single air compressor system, you can forget about having to search out an air compressor to inflate your air springs ever again!</span></p>
<ul>
<li>
<p><strong>With the touch of a button, control the pressure in your air springs from the cab of your vehicle.</strong>&nbsp;This is extremely convenient for changes in load or road conditions. If you&rsquo;ve just hooked up your RV, trailer or put a load in the bed of your truck, you can inflate your air springs to the desired pressure right from the cab. No more searching for a gas station compressor to find air!</p>
</li>
<li>
<p><strong>The gauge mounts in your vehicle&rsquo;s cab and operates regardless of whether you are parked or on the road.</strong>&nbsp;The user-friendly gauge has easy-to-use inflate and deflate buttons to let you quickly inflate or deflate your vehicle&rsquo;s air spring pressure. Mount in the included mounting cup, flush mount or insert into any 2 1/8 inch gauge pod.</p>
</li>
<li>
<p>LoadController Single On-Board Air Compressor System provides single path airflow for your vehicle&rsquo;s air springs. This means your left and right air springs inflate and deflate equally to the same pressure. For independent control of the left and right air springs, see our LoadController Dual products (part numbers 25852 and 25856).</p>
</li>
<li>
<p>This system includes a heavy duty compressor, manifold, wiring harness, air lines, gauge, customizable gauge pod and all the hardware you need to install. The heavy duty compressor is best for frequent users of the system, and it inflates faster and more quietly than our standard compressor.</p>
</li>
<li>
<p>The compressor mounts easily to your vehicle&rsquo;s frame and attaches to an air line that runs to your air springs</p>
</li>
<li>
<p>You can install the system yourself in a few hours with the help of a fully illustrated easy-to-follow installation manual. If you prefer, have one of our skilled dealer/installers throughout the US and Canada take care of it for you.</p>
</li>
<li>
<p>As an added safety measure, LoadController Single automatically senses low air spring pressure and immediately activates to maintain a safe pressure level.</p>
</li>
<li>
<p>All Air Lift compressor systems are compatible with any brand of air springs.</p>
<p><em>Easy Installation</em></p>
<p>The LoadController Single system installs with common mechanic tools in a few hours. Follow these steps:</p>
</li>
</ul>
<ul>
<li>
<p>Install the compressor using the hardware provided.</p>
</li>
<li>
<p>Mount the gauge</p>
</li>
<li>
<p>Install the electrical components</p>
<p>Details and installation time vary by application. A complete illustrated instruction manual is included with each kit.</p>
<p>&nbsp;</p>
</li>
</ul>","<p><span style=""font-family: Calibri;"">LoadController Single On Board Air Compressor System is the quick and convenient way to inflate and deflate your vehicle&rsquo;s air springs while on the go. The last place you probably want to drive your loaded vehicle and trailer is into a tiny gas station to fill up your air springs. With a LoadController Single air compressor system, you can forget about having to search out an air compressor to inflate your air springs ever again!</span>&nbsp;</p>","291.9000","0.00","1","0","1","1","4","6.000","Suspension Accessories/Air Lift Air Bags & Accessories/Air Lift Compressors & Accessories","/AL25854__lg.jpg","/AL25854__lg.jpg","/AL25854__lg.jpg","","","","","","","","","","","","","","","","","1:262.71","1:262.71"
"AL 25856","Default","simple","admin","","","LOAD CONTROLLER DUAL HEAVY DUTY COMPESSOR SYSTEM - AIR LIFT","<p>LoadController Dual On Board Air Compressor System is the quick and convenient way to inflate and deflate your vehicle''s air springs while on the go. The last place you probably want to drive your loaded vehicle and trailer is into a small gas station to fill up your air springs. With a LoadController Dual air compressor system, you can forget about having to search out an air compressor to inflate your air springs ever again!</p>
<p>With the touch of a button, control the pressure in your air springs from the cab of your vehicle.This is extremely convenient for changes in load or road conditions. If you&rsquo;ve just hooked up your RV, trailer or put a load in the bed of your truck, you can inflate your air springs to the desired pressure right from the cab. No more searching for a gas station compressor to find air!</p>
<p>LoadController Dual On-Board Air Compressor System provides dual path airflow for your vehicle''s air springs. This means your left and right air springs can be set to independent pressures. This is particularly helpful if you have more weight on one side of the vehicle than the other. It also prevents air from transferring between air springs, allowing for more stable cornering and body roll. For equal inflation/deflation of the left and right air springs, see our LoadController Single product page.</p>
<p>The gauge mounts in your vehicle''s cab and operates regardless of whether you are parked or on the road. The user-friendly gauge has easy-to-use inflate and deflate buttons to let you quickly inflate or deflate your vehicle''s air spring pressure. Mount in the included mounting cup, flush mount or insert into any 2 1/8 inch gauge pod.</p>
<p>This system includes a heavy duty compressor, wiring harness, air lines, gauge, customizable gauge pod for easy installation and all the tools you need to install.</p>
<p>The compressor mounts easily to your vehicle''s frame and attaches to an air line that runs to your air springs</p>
<p>This system includes a heavy duty compressor, which is best for frequent users of the system, and it inflates faster and more quietly than our standard compressor.</p>
<p>As an added safety measure, LoadController Dual automatically senses low air spring pressure and immediately activates to maintain a safe pressure level.</p>
<p>All Air Lift compressor systems are compatible with any brand of air springs.</p>
<p>The LoadController Dual installs with common mechanic tools in a few hours.</p>","<p>LoadController Dual On Board Air Compressor System is the quick and convenient way to inflate and deflate your vehicle''s air springs while on the go. The last place you probably want to drive your loaded vehicle and trailer is into a small gas station to fill up your air springs. With a LoadController Dual air compressor system, you can forget about having to search out an air compressor to inflate your air springs ever again!</p>
<p>With the touch of a button, control the pressure in your air springs from the cab of your vehicle.This is extremely convenient for changes in load or road conditions. If you''ve just hooked up your RV, trailer or put a load in the bed of your truck, you can inflate your air springs to the desired pressure right from the cab. No more searching for a gas station compressor to find air!</p>
<p>LoadController Dual On-Board Air Compressor System provides dual path airflow for your vehicle''s air springs. This means your left and right air springs can be set to independent pressures. This is particularly helpful if you have more weight on one side of the vehicle than the other. It also prevents air from transferring between air springs, allowing for more stable cornering and body roll. For equal inflation/deflation of the left and right air springs, see our LoadController Single product page.</p>","444.5500","0.00","1","0","1","1","4","7.000","Suspension Accessories/Air Lift Air Bags & Accessories/Air Lift Compressors & Accessories","/AL25856__lg.jpg","/AL25856__lg.jpg","/AL25856__lg.jpg","","","","","","","","","","","","","","","","","1:400.10","1:400.10"
simoncarre commented 3 years ago

Hello @dankoz51,

Our reader is based on the native product CSV reader. Line by line reading is managed by native code. Can you try on the new version of Akeneo / bundle?

mbraeuner commented 3 years ago

Hi @simoncarre,

the problem is here: https://github.com/ClickAndMortar/AdvancedCsvConnectorBundle/blob/8e3f48ada2c62022944cd908e4f9c1d271419998/Helper/ImportHelper.php#L33

The Advacned Connector splits files into 1000 line chunks. If the 1000st linebreak is inside a data line with line breaks, it will break the data of one product line and split it over 2 files.

You have to refactor splitting the file: https://github.com/ClickAndMortar/AdvancedCsvConnectorBundle/blob/8e3f48ada2c62022944cd908e4f9c1d271419998/Resources/bin/split-csv-files.sh#L52

split splits at line breaks not at csv data line end.