M
Mark Toth
Hello,
I have a text that containing " char and want to delete it from the
text before I read it to the database with fasterCSV.
This is "the Text".
===>
This is the Text.
What is the command to simple replace the " char with nothing?
This is the code so you can see what I am trying to do:
file = 'c:\filename.txt'
$KCODE = "utf8"
FasterCSV.foreach(file.tr('"', ''), :headers =>true, :col_sep
=>"\t", :row_sep =>"\n") do |row|
@PriceListFileRow = row
next if row.empty?
a_product = Product.new(
:sku => row[0] ,
:name => row[1] ,
rice => row[2] ,
:salestart => row[3] ,
:saleend => row[4] ,
:category => row[5] ,
:manufacturer => row[6] ,
:manufacturersku => row[7] ,
thersku => row[8] ,
roducturl => row[9] ,
:stockstatus => row[10] ,
:shipping => row[11])
a_product.save
- The problem is that fasterCSV read the file before it´s been converted
with the " char.
- The second problem that I have with Rails is that åäö letters doesn´t
been imported correctly even when I use the $KCODE = "utf8" code.
Thank you again and waiting for your answer!
Best regards,
Mark
I have a text that containing " char and want to delete it from the
text before I read it to the database with fasterCSV.
This is "the Text".
===>
This is the Text.
What is the command to simple replace the " char with nothing?
This is the code so you can see what I am trying to do:
file = 'c:\filename.txt'
$KCODE = "utf8"
FasterCSV.foreach(file.tr('"', ''), :headers =>true, :col_sep
=>"\t", :row_sep =>"\n") do |row|
@PriceListFileRow = row
next if row.empty?
a_product = Product.new(
:sku => row[0] ,
:name => row[1] ,
rice => row[2] ,
:salestart => row[3] ,
:saleend => row[4] ,
:category => row[5] ,
:manufacturer => row[6] ,
:manufacturersku => row[7] ,
thersku => row[8] ,
roducturl => row[9] ,
:stockstatus => row[10] ,
:shipping => row[11])
a_product.save
- The problem is that fasterCSV read the file before it´s been converted
with the " char.
- The second problem that I have with Rails is that åäö letters doesn´t
been imported correctly even when I use the $KCODE = "utf8" code.
Thank you again and waiting for your answer!
Best regards,
Mark