Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » CVS import - unknown number of columns

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 340 Views
  • Futureweb
    Avatar
    Community Member
    232 Posts

    CVS import - unknown number of columns Link to this post

    Hi,

    I have a situation where my client will be uploading CSV files.

    The first column defines various 'questons', and the subsequent rows define different peoples answers.

    There are about 100 rows (questions), and the number of columns (answers) keeps growing.

    Instead of creating a database table with all the rows matching the CSV file, I was thinking of having a table with 'question, answer, name'
    name is the name of the person - which is the first question.

    So

    name: jon , Stu , Bob
    age: 31, 20, 56
    nationality: uk, nz, usa
    height: 5ft, 6ft,2ft

    becomes a serious of rows

    question: answer: name
    age: 31, jon
    nationality: uk, jon
    height: 5ft, jon
    age: 20, Stu
    nationality: nz, Stu
    height: 6ft, Stu
    age: 56, Bob
    nationality: usa, Bob
    height: 2ft, Bob

    I would easily be able to search through this, and if the client adds more questions (rows) to the CSV file they just get loaded in.

    However, I'm not really sure where to start... Anyone have any ideas?

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: CVS import - unknown number of columns Link to this post

    Hi,

    Look into extending "CsvBulkLoader". function processRecord this will allow you to read the csv and write to any number of dataobjects with any logic that you require

    340 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.