Closed jeanbaptisteb closed 3 years ago
For those who are interested, here's a quick-and-dirty workaround, which involves creating a dataframe of fake answers:
from lxml import etree
import pandas
from limepy.wrangle import Survey, Question
lss =<path to the LSS file>
root = etree.parse(lss)
xpath = "/document/questions/rows/row/title"
titles = root.xpath(xpath)
fake_answers = [[""]*len(titles),
[""]*len(titles)
]
df = pandas.DataFrame(fake_answers, columns=[title.text for title in titles])
with open(lss) as f:
my_structure = f.read()
my_survey = Survey(df, my_structure)
Thanks for your feedback! I’ll take a look at it; it may take a couple days before I get round to this
Thanks for your quick reply! I've been able to explore the file's structure with the workaround I mentioned above, so this feature is not something urgent for me. But it sure would be great if the library could do this natively!
I considered making it possible to create an ‘empty’ Survey object by passing None instead of a dataframe. However, it turned out this wasn’t so easy to implement as I first thought. So thanks for offering the workaround for anyone who’s interested in this!
Hi,
Nice library.
Here's my problem: I have a survey structure file (LSS format), without any answer yet.
I'd like to use this library to explore the survey structure. But from the example given on the main page and from the source code, my understanding is that it's necessary to have some dataframe containing the answers, in order to read the structure file.
Am I correct, or is there a way to read the LSS file on its own?
If it's not currently possible, it would be a pretty useful feature!
Thanks.