0

I'm currently doing a crawler for a website, and my goal is to have a CSV, with a name in the first column and an image the second one, which is inserted with a Ruby script using the CSV#open method.

I have already used this method but I don't know, and I don't find information about the problematic that is to insert an image into a column.

Is it really possible? If not, which functionality would you use to have a list with string + image after crawling?

Sebastián Palma
  • 32,692
  • 6
  • 40
  • 59

1 Answers1

0

A CSV (Comma Separated Values) file is a TEXT file which as the name implies has various values separated by commas, expressed using plain ASCII, or sometimes unicode. It is intended as a light weight way to transfer tabular data between different computer systems or programs. You can use it to spit out a table in a database, or the VALUES in something like a spreadsheet. The normal convention is for the first row(line) of the file to contain names or labels that represent what that column contains, and then data in the subsequent rows.

As such, there really is no practical way to embed an image within a CSV file. This is not a limitation of Ruby or Watir, but a limitation of textfiles which spans pretty much all languages and operating systems.

To do what you want you would be better off to save the images into a specific directory using unique filenames and insert those filenames into the CSV file.

Chuck van der Linden
  • 6,660
  • 2
  • 28
  • 43