fixed-length-record

Is there an smart way to write a fixed length flat file?

风格不统一 提交于 2019-12-22 03:23:11
问题 Is there any framework/library to help writing fixed length flat files in java? I want to write a collection of beans/entities into a flat file without worrying with convertions, padding, alignment, fillers, etcs For example, I'd like to parse a bean like: public class Entity{ String name = "name"; // length = 10; align left; fill with spaces Integer id = 123; // length = 5; align left; fill with spaces Integer serial = 321 // length = 5; align to right; fill with '0' Date register = new Date

.NET Library For Fixed Length Text Files

烂漫一生 提交于 2019-12-18 12:32:16
问题 I'm looking for a .NET (much preferably open source in C#) library for dealing with fixed length field text files. It wouldn't be too much to write one, but existing, tested work is always nicer, to start with. I will be extracting data in fixed length fields from files produced by a PBX. Each PBX has its own file format, as well a set of record formats. I'm looking for a library with a nice a simple way of using dynamic file and record formats, e.g. read from an INI or XML file. EDIT: I had

.NET Library For Fixed Length Text Files

一笑奈何 提交于 2019-12-18 12:32:02
问题 I'm looking for a .NET (much preferably open source in C#) library for dealing with fixed length field text files. It wouldn't be too much to write one, but existing, tested work is always nicer, to start with. I will be extracting data in fixed length fields from files produced by a PBX. Each PBX has its own file format, as well a set of record formats. I'm looking for a library with a nice a simple way of using dynamic file and record formats, e.g. read from an INI or XML file. EDIT: I had

C++. After writing into a relative file, I cannot display the content

流过昼夜 提交于 2019-12-08 03:49:33
问题 I can write into a relative file 1 , then when I try to read the content and display it on the screen (to check if data are actually into the file), I do not have the records which I believe are already present in the file. I am using Dev-C++. Any help will be appreciated. The code is below; #include <iostream> // cin, cout #include <iomanip> #include <fstream> #include <conio.h> using namespace std; #define SIZE 10 struct client // Client record { int account; // from 1 to SIZE char name[20]

Is there an smart way to write a fixed length flat file?

主宰稳场 提交于 2019-12-05 01:13:52
Is there any framework/library to help writing fixed length flat files in java? I want to write a collection of beans/entities into a flat file without worrying with convertions, padding, alignment, fillers, etcs For example, I'd like to parse a bean like: public class Entity{ String name = "name"; // length = 10; align left; fill with spaces Integer id = 123; // length = 5; align left; fill with spaces Integer serial = 321 // length = 5; align to right; fill with '0' Date register = new Date();// length = 8; convert to yyyyMMdd } ... into ... name 123 0032120110505 mikhas 5000 0122120110504

How do I read fixed-length records in Perl?

家住魔仙堡 提交于 2019-12-04 00:07:18
问题 What's the best way to read a fixed length record in Perl. I know to read a file like: ABCDE 302 DEFGC 876 I can do while (<FILE>) { $key = substr($_, 0, 5); $value = substr($_, 7, 3); } but isn't there a way to do this with read/unpack? 回答1: Update: For the definitive answer, see Jonathan Leffler's answer below. I wouldn't use this for just two fields (I'd use pack/unpack directly), but for 20 or 50 or so fields I like to use Parse::FixedLength (but I'm biased). E.g. (for your example)

Regex for fixed width field

天涯浪子 提交于 2019-12-01 06:42:33
I need to match a fixed width field on a file layout with a regular expression. The field is numeric/integer, always have four characters and is included in the range of 0..1331. When the number is smaller than 1000, the string is filled with left zeros. So all these examples are valid: 0000 0001 0010 1000 1331 But the following must be not accepted: 1 01 10 100 4759 It would be nice if I could enforce this restriction only with regex. After playing a bit, I yielded the expression \0*[0-1331]\ . The problem is that it does not restrict the size to four characters. Of course I could do \000[0-9

Regex for fixed width field

核能气质少年 提交于 2019-12-01 04:58:37
问题 I need to match a fixed width field on a file layout with a regular expression. The field is numeric/integer, always have four characters and is included in the range of 0..1331. When the number is smaller than 1000, the string is filled with left zeros. So all these examples are valid: 0000 0001 0010 1000 1331 But the following must be not accepted: 1 01 10 100 4759 It would be nice if I could enforce this restriction only with regex. After playing a bit, I yielded the expression \0*[0-1331]

How do I read fixed-length records in Perl?

痴心易碎 提交于 2019-12-01 03:01:45
What's the best way to read a fixed length record in Perl. I know to read a file like: ABCDE 302 DEFGC 876 I can do while (<FILE>) { $key = substr($_, 0, 5); $value = substr($_, 7, 3); } but isn't there a way to do this with read/unpack? runrig Update: For the definitive answer, see Jonathan Leffler's answer below. I wouldn't use this for just two fields (I'd use pack / unpack directly), but for 20 or 50 or so fields I like to use Parse::FixedLength (but I'm biased). E.g. (for your example) (Update: also, you can use $/ and <> as an alternative to read($fh, $buf, $buf_length)...see below): use

Is xslt good approach to convert text to xml structure?

試著忘記壹切 提交于 2019-11-30 10:21:18
I am trying to find a better solution to convert a plain text (but with predefined lengths for each field) to xml. For example the input text can be "Testuser new york 10018", the first 11 characters indicates user name, next 12 character indicates city and next 5 characters indicates zip code. So I need to form a xml from the above string with predefined field lengths. I am thinking 2 approaches Define a business entity and fill the entity properties by using substring functions on the input text and then serialize the entity to xml Predefine the xml structure, use xslt to navigate to each