read data from external excel file

Discussions about CSEntry
Post Reply
PHINOJOSA
Posts: 45
Joined: April 16th, 2023, 10:31 pm

read data from external excel file

Post by PHINOJOSA »

Greetings

Could someone help me, I must develop a questionnaire on food table in which I must enter a code of a food and search for this code in the external excel file and copy the data of that food.

For example orange code A0046 in excel this code has columns for energy, protein, carbohydrates, etc. and I want those values of that code to be passed to CSPro to assigned variables.

please if you could help me.
Attachments
Table_foods_nutrients.PNG
Table_foods_nutrients.PNG (20.31 KiB) Viewed 6020 times
justinlakier
Posts: 152
Joined: November 21st, 2022, 4:41 pm

Re: read data from external excel file

Post by justinlakier »

greetings,

please check the Excel to CSPro help documentation. You can find Excel to CSPro under Tools, and use it to map Excel data to a CSPro format, creating a matching dictionary if you don't have one already. You can then use loadcase to find the case with the matching ID code and pass values in logic.

Hope this helps,
Justin
PHINOJOSA
Posts: 45
Joined: April 16th, 2023, 10:31 pm

Re: read data from external excel file

Post by PHINOJOSA »

Thank you very much justinlakier

I will put your advice into practice and hope to achieve my goal, if for some reason due to my inexperience I will keep asking for your help,

Thank you very much
PHINOJOSA
Posts: 45
Joined: April 16th, 2023, 10:31 pm

Re: read data from external excel file

Post by PHINOJOSA »

Greetings justinlakier

I have created a small survey to be able to practice what you indicated me, I made the attempt but it does not give me the result that I want, if you could help me I attach files that I have created.

Thank you in advance for your help.

Oh, one last question, how can I go to the last variable of my last row of ROSTER?

When I use move to it doesn't work.
Attachments
R24.zip
(116.07 KiB) Downloaded 204 times
justinlakier
Posts: 152
Joined: November 21st, 2022, 4:41 pm

Re: read data from external excel file

Post by justinlakier »

Hi,

If you look in the .zip file I returned, you'll see ExampleSpec.xl2cs. This is a saved version of Excel to CSPro, into which I plugged your excel file, dictionary, and output data file. After specifying which worksheet of that excel sheet I wanted to use and which columns of that worksheet corresponded to which dictionary items, running it converted all excel items to cases in the data file. The .ent file now prefills based on the code. If you want to run excel to cspro again you can find it under Tools in the tool bar or open the saved specification and make edits.

For your question on the last variable of the last row of a roster, I recommend using Skip (which skips over intermediary fields) or Advance (which advances through intermediary fields) rather than Move. Index the last variable using the number of the last row. So for example, if your roster's last column is Last_Var, and there are 9 rows, you could Skip To Last_Var(9).

Hope that helps,
Justin
Attachments
R24.zip
(490.89 KiB) Downloaded 253 times
PHINOJOSA
Posts: 45
Joined: April 16th, 2023, 10:31 pm

Re: read data from external excel file

Post by PHINOJOSA »

Thank you very much

With the file you have sent and your message I could realize my mistake and why I was not getting the expected result, thank you very much.

Now everything works. :)

Sincerely

Paul Hinojosa
Post Reply