kristof65 said:Just an idea to throw out there, given my limited knowledge of the .sec format and XML, but wouldn't XML be the "solution" to this?
As I understand, part of the XML file structure defines the data structure within in terms that any XML capable program can translate. So if someone were to convert the .sec files to XML, any one with recent versions of MS Office and Open Office (among others) could use the files, while specialty programs could be written to extract the appropriate data from any XML sector file that used the correct headings, extra data or different formatting excluded.
All that would really need to be defined by the community would be a set of "standard" tags.
dorward said:CSV is not a nice format, it is even less readable than XML.
I'd probably be tempted to use the Config::General format: http://search.cpan.org/~tlinden/Config-General-2.42/General.pm#CONFIG_FILE_FORMAT
... except I don't know what the state of play for parsers for it is outside Perl land.
dorward said:CSV is not a nice format, it is even less readable than XML.
I'd probably be tempted to use the Config::General format: http://search.cpan.org/~tlinden/Config-General-2.42/General.pm#CONFIG_FILE_FORMAT
... except I don't know what the state of play for parsers for it is outside Perl land.
simonh said:CSV is very compact, so would be good for storing whole sectors of data. With a header line it can also be reasonably flexible. I'd be fine with it only if the column meanings are defined by the headers and not hard-coded, otherwise it's almost as rigid as fixed-field.
My understanding of this is that many programs are already built to parse the XML documents and that in XML documents, the data structure is part of the file information.simonh said:XML is ok, but less human readable and more work to machine-parse but I'd live with it.
kristof65 said:My understanding of this is that many programs are already built to parse the XML documents and that in XML documents, the data structure is part of the file information.simonh said:XML is ok, but less human readable and more work to machine-parse but I'd live with it.
So while someone looking at the raw XML file might find it harder to read, someone trying to open it with OpenOffice or MS Office 2007 would find it nicely formatted for them, assuming whomever created the XML file in the first place set it up properly.
I suggested it thinking mainly of trying to make the data more accessible to the casual computer user using tools/procedures they already know, rather than making it easier for the programmer or macro wiz who wants to manipulate the data. The people who want to manipulate the data typically have the know-how necessary knowledge to extract what they want anyway.
hhawk said:Do you mean human readable or machine readable?
hhawk said:As far as human readable, it is not too bad. Just load it in excel or open office.
simonh said:Config format is supported in the Python standard library, and there's a top notch open source third party library that's even better.
kristof65 said:So while someone looking at the raw XML file might find it harder to read, someone trying to open it with OpenOffice or MS Office 2007 would find it nicely formatted for them, assuming whomever created the XML file in the first place set it up properly.
dorward said:You then end up with lots of horizontal scrolling, which isn't ideal.
dorward said:I think the best approach is a format that programmers can get up and running with easily so that they can build tools to edit it. From this perspective, XML is possibly the best option, since it has lots of parsers and generators available for it. It isn't as readable or as easy to edit by hand as Config General files, but the ease of having parsers available in pretty much every language under the sun probably offsets that.
import csv
# Private function used to build a list of dictionaries where each dictionary is a csv record (line)
def build_ldict(fields,csvlist):
return [ dict(zip(fields,i)) for i in csvlist]
# opens and parses filename and returns a list of dictionaries where each dictionary is a csv record (line)
# first line in the csv provides the name for each column. This name is the key in the dictionary to access the respective column for each csv record.
def csv_file_to_ldict(filename):
f = open(filename,"r")
r = csv.reader(f)
records = [i for i in r]
f.close()
return build_ldict(records[0],records[1:])
# creates the csv file filename from the list of dictionaries ldict
def ldict_to_csv_file(filename, ldict):
keys = ldict[0].keys()
f = open(filename,"w")
print >>f, ','.join(keys)
for i in ldict:
values = [ str(i[j]) for j in keys ]
print >>f, ','.join(values)
f.close()
return
GypsyComet said:Try as you might, ignoring the CT/MT 80 character line standard for UWP is not an option. At the very least, any current utility will need to be able to parse this text format, and output it for in-game use.
You know... at a table with friends.
import string
# Load a SEC file and return a list of dictionaries
# Each dictionary represents a specific system
def SEC_file_to_ldict(filename):
# private functions
def SEC_Line_to_dict(line):
l = string.ljust(line,80)
return { 'Name' : l[0:14],
'HexNbr' : l[14:18],
'UWP' : l[19:28],
'Bases' : l[30:31],
'Trade Codes' : l[32:47],
'Zone' : l[48:49],
'PBG' : l[51:54],
'Allegiance' : l[55:57],
'Stellar Data': l[58:74]}
def FindSECStart(lines):
at = 0
for l in lines:
test = SEC_Line_to_dict(l)
test = test['UWP']
if test[7] == '-':
if test[0:7].isalnum() and test[8:9].isalnum():
return at
at += 1
return at
# Start of function
f = open(filename, "r")
lines = [i.strip('\n') for i in f]
f.close()
startingline = FindSECStart(lines)
return [ SEC_Line_to_dict(l) for l in lines[startingline:]]
This is very important. The SEC file format is primarily a human readable format. All of the other formats under discussion are primarily for machine reading, with the ability to be read by a human. Until the computer becomes a integral part of the table top role playing experience, this requirement for a human readable first format for information won't change.GypsyComet said:Try as you might, ignoring the CT/MT 80 character line standard for UWP is not an option. At the very least, any current utility will need to be able to parse this text format, and output it for in-game use.
You know... at a table with friends.
tjoneslo said:This is very important. The SEC file format is primarily a human readable format. All of the other formats under discussion are primarily for machine reading, with the ability to be read by a human. Until the computer becomes a integral part of the table top role playing experience, this requirement for a human readable first format for information won't change.
Deniable said:XML is overkill and has its own set of problems.
Deniable said:The less said about XHTML the better.
Deniable said:CSV will either have to have limited line length or will be as unreadable as XML.
Deniable said:The big thing about SEC is that it is a semi-formalized form of the sector data seen in CT/MT and later books. It's easy to interpret by eye
Deniable said:and is supported by a lot of tools. Unless someone builds a better set of tools that use a new format, I don't see it getting supplanted.
Then why bother with a human readable data format at all? If the primary (only) way to use the data is through a (your) tool, all the objections presented here for human readability are irrelevant. We should use whatever format works best for the tools.dorward said:There's no need for the format to be designed to be used on paper at the tabletop. Nobody reads raw Word documents on paper (or at all for that matter), they use tools to transform it into something friendlier.