Please use our GitHub Issues page for all new support inquiries. If you need to contact us directly, please e-mail [email protected]

Hi all, I would like to import Area, Height and Width values from a csv file that has unique values for each cell into my datavyu opf file.

Example CSV: Area,Height,Width,Document 2679,75,48,499

The Document column denotes the cell number that I would like the data to be imported to. Area, Height and Width are the values for the cell, in this case the datavyu cell number 499 has an area of 2679, height of 75 and width of 48.

Current code looks something like this.

  for i in 1..frames
  time = i
  cell = cell_info.make_new_cell()

  cell.change_code("offset", time * (1000/30))
  cell.change_code("imgw", vwidth)
  cell.change_code("imgh", vheight)

  CSV.foreach('C:\\Users\\Main\\Desktop\\Untitled.csv', headers: true) do |row|
  #area, height, width, document = row
    x = 1
    document = "document"
    narea = row[1][x].to_i
    nheight = row[2][x].to_i
    nwidth = row[3][x].to_i

        if row[x][4].to_i == i
#This is where the script checks the csv if area, height and width values exist for the cell being created, if so, it uses those values.
        cell.change_code("pixelarea", narea)
        cell.change_code("selectwidth", nwidth)
        cell.change_code("selectheight", nheight)

The ruby script runs successfully but does not populate the cells with the data in the csv. I think my error is either in my loop or in defining the csv array properly.

Any help would be greatly appreciated.

Thank You!

asked 03 Jan '17, 02:40

patelav07's gravatar image

accept rate: 0%

edited 03 Jan '17, 03:17

Can you make sure the are, height, width, and document values are read properly for the rows of the csv file? E.g. put this line of code: puts [narea, nheight, nwidth].join(',') on the line before the if-statement.

I see that you commented out the line where you split the line into the area, width, height, etc. Did that not work?

permanent link

answered 03 Jan '17, 14:54

Shohan%20Hasan's gravatar image

Shohan Hasan ♦♦
accept rate: 14%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 03 Jan '17, 02:40

question was seen: 4,260 times

last updated: 03 Jan '17, 14:54

powered by OSQA