best way of sequencing CSV data for USB import

Status
Not open for further replies.

oem_odm

New Member
Hi all, I've been pondering over this for about a week with no luck on a simple solution.

A usb device will import data in TXT/CSV format from PC software - amoung other things, the main purpose is for the USB device to display categories (which users select with up and down keys on the keypad). There could be any number of categories set by the user on pc, downloaded into the device, and then referred to when using the device. Categories can have sub-categories, and sub-categories can have sub-sub-categories.

Categories can be deleted....changed....modified in name, so, each category is assigned a unique id number on the pc software. An example of categories would be teams, and then sub-categories would be players. The CSV would be something like:

team A, 111
team B, 112
team C, 113

A user might delete team B, and rename another team:

team A, 111,
team baldrick, 114
team C, 113

Categories always keep there same id number so any data saved to that category doesnt get lost. Categories should be saved alphabetically, by their name, not by their unique id number - so when scrolling on the device keypad (after downloading the txt file to the device) - the user knows how far to wait/go for a certain category.

The problem.. is...how do sub-categories get listed?

team a, 111
player 1, 111.1
player 2, 111.2
player 3, 111.3

Sub cat. unique id is an extension of parent category id. Each parent category can have true or false indicator if it has or doesn't have sub-categories.

I don;t know how the txt file exported from pc software into the device via usb should be sequenced/listed, as, parent categories should be alphabetical by name, and sub-categories be alphabetical by name under each respective parent category.

team a, 111
player 1, 111.1
player 2, 111.2
player 3, 111.3
team baldrick, 114
player 1, 114.1
player 2, 114.2
player 3, 114.3

As above, how would software export such category listing in this order, can't list by id number as these might change when adding/deleting......

My other idea was to make a seperate code string (not sure if right word) for each sub-category. For example

team A, 111, 1
team baldrick, 114, 1
team C, 113, 1

The third digit true/false if there are sub categories, if true, there will be a string in the same output code file with the list of sub-categories for that parent category, in case of team A,

sub string 111
player 1, 111.1
player 2, 111.2
player 3, 111.3

So the MCU on the device would work something like:

Show parent category
(if user wants to see the sub-category) they press left/right keypad button
If they do that, MCU searches same txt imported file in memory for sub-string of the parent categories unique id number. There, will be an alphabetical list of sub-categories, with unique id numbers (which will be out of sequence).

This way, the TXT file can easily be ordered, and the MCU can easily navigate round....

but... i just dont really know......

any advice/help/pointers would be great......

thanks
 
Must the transferred data be in textual format? Specifically CSV? Perhaps you can hold the information in XML format on the PC (perfect for these kind of things, easy to edit manually) and then encode it in some easy to parse, concise binary format out the USB
 
Hi Pavius,

This is a bit over my head I'd like to know the simplest way to organise alphabetically listed parent categories, and alphabetically lists sub-categories - according to their names.....like above. I'd like to know the format of the output file (actually see how it would organise the data). ....
 
In your example, your data represented in XML would look something like:

Code:
<teams>
	<team>
		<team-name>your team name</team-name>
		<other-team-attribute>blah</other-team-attribute>
		<players>
			<player>
				<player-name>some name</player-name>
			</player>
			<player>
				<player-name>some other name</player-name>
			</player>
			...
		<players>
	</team>
	
	<team>
		...
	</team>

	...
</teams>

XML is much richer than the above example, but that's the gist of things.

You can google "nested XML example" - you'll come up with things like **broken link removed**. If you feel that XML suites your project, there are literally thousands of XML tutorials on the web.
 
Hi Pavius, drop me a private message as I'd really appreciate a 10min chat on msn or skype to understand something simple.....

if anyone else can help..with a chat - that would be awesome..im here for a while online..

thanks
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…