fileparsing

Generating data structures by parsing plain text files

断了今生、忘了曾经 提交于 2019-12-05 07:07:26
I wrote a file parser for a game I'm writing to make it easy for myself to change various aspects of the game (things like the character/stage/collision data). For example, I might have a character class like this: class Character { public: int x, y; // Character's location Character* teammate; } I set up my parser to read in from a file the data structure with syntax similar to C++ Character Sidekick { X = 12 Y = 0 } Character AwesomeDude { X = 10 Y = 50 Teammate = Sidekick } This will create two data structures and put them in a map <std::string, Character*> , where the key string is

What is the best way to read a text file two lines at a time in Java?

空扰寡人 提交于 2019-12-04 04:37:11
问题 BufferedReader in; String line; while ((line = in.readLine() != null) { processor.doStuffWith(line); } This is how I would process a file line-by-line. In this case, however, I want to send two lines of text to the processor in every iteration. (The text file I'm processing essentially stores one record on two lines, so I'm sending a single record to the processor each time.) What's the best way of doing this in Java? 回答1: Why not just read two lines? BufferedReader in; String line; while (

What is the best way to read a text file two lines at a time in Java?

天涯浪子 提交于 2019-12-01 21:10:55
BufferedReader in; String line; while ((line = in.readLine() != null) { processor.doStuffWith(line); } This is how I would process a file line-by-line. In this case, however, I want to send two lines of text to the processor in every iteration. (The text file I'm processing essentially stores one record on two lines, so I'm sending a single record to the processor each time.) What's the best way of doing this in Java? Why not just read two lines? BufferedReader in; String line; while ((line = in.readLine() != null) { processor.doStuffWith(line, in.readLine()); } This assumes that you can rely

Simple data storing in Python

怎甘沉沦 提交于 2019-12-01 00:01:40
I'm looking for a simple solution using Python to store data as a flat file, such that each line is a string representation of an array that can be easily parsed. I'm sure python has library for doing such a task easily but so far all the approaches I have found seemed like it would have been sloppy to get it to work and I'm sure there is a better approach. So far I've tried: the array.toFile() method but couldn't figure out how to get it to work with nested arrays of strings, it seemed geared towards integer data. Lists and sets do not have a toFile method built in, so I would have had to

Simple data storing in Python

心不动则不痛 提交于 2019-11-30 18:09:14
问题 I'm looking for a simple solution using Python to store data as a flat file, such that each line is a string representation of an array that can be easily parsed. I'm sure python has library for doing such a task easily but so far all the approaches I have found seemed like it would have been sloppy to get it to work and I'm sure there is a better approach. So far I've tried: the array.toFile() method but couldn't figure out how to get it to work with nested arrays of strings, it seemed

how to read, parse the SBM file format from Superbible Opengl

≡放荡痞女 提交于 2019-11-30 09:20:58
问题 Calling on experts, gurus, and anybody to help read and parse a file in python. On page 751 of 6th ed. or page 800 of 7th ed. of Superbible OpenGL there is Appendix B. The SBM File Format that seems to explain well the format to some extent. I have tried to implement in python a reader of this file format. OK, progress has been made. I have merged Rabbid76 amazing code to the source provided. Though I am attempting to make additional headway. Update Jun 23, 2019 - major progress, fixed the

how to read, parse the SBM file format from Superbible Opengl

泄露秘密 提交于 2019-11-29 15:15:00
Calling on experts, gurus, and anybody to help read and parse a file in python. On page 751 of 6th ed. or page 800 of 7th ed. of Superbible OpenGL there is Appendix B. The SBM File Format that seems to explain well the format to some extent. I have tried to implement in python a reader of this file format. OK, progress has been made. I have merged Rabbid76 amazing code to the source provided. Though I am attempting to make additional headway. Update Jun 23, 2019 - major progress, fixed the error about glVertexAttribPointer(i, ... error. Same day, fixed the Python cannot find the variable first

IOError when trying to open existing files

情到浓时终转凉″ 提交于 2019-11-27 16:26:38
I have a small issue with a python program that I wrote to extract some information from a special text file. The loop (code below) needs to execute my function extract_zcoords() over 500 files (1 file gives one list) so that I can build a dataset. import os def extract_zcoord(filename): f = open(filename, 'r') ... # do something with f ### LOOP OVER DIRECTORY location = '/Users/spyros/Desktop/3NY8MODELSHUMAN/HomologyModels' for filename in os.listdir(location): extract_zcoord(filename) THE ERROR: The IOException No such file or directory is the one that occurs, so for some reason python is