How to read/resolve mif file created by Mapinfo - java

I want to resolve some .mif files with C# or Java to get the coordinate information.But there are few documents about this kind of file and I'm a newcomer ... Maybe I can resolve them simply using InputStream but I want to know how others do this :P
Also if you know the meaning of each line please tell me :-D
With great pleasure.
The head of mif file like this:
Version 300
Charset "WindowsSimpChinese"
Delimiter ","
CoordSys Earth Projection 1, 104
Columns 9
guid Char(64)
sr_id Char(64)
mp_id Char(64)
name Char(128)
catalog Char(9)
floor Char(8)
tag Char(254)
elevation Char(6)
rank Char(2)
Data
And the data like this:
Region 1
5
116.312476 40.027556
116.312302 40.027541
116.312292 40.027609
116.312468 40.027623
116.312476 40.027556
Pen (1,2,0)
Brush (1,0,16777215)
Center 116.312384 40.027582

Related

Read a text File which has numeric columns (like -10.0, -9.9, +9.9 etc.) through Apache Flink

I have requirement where I need to read a file which is generated by another application and file has 201 numeric column name like: -10.0, -9.9, -9.8, -9.7 .......0.....+9.7, +9.8, +9.9, +10.0 so total I have 201 columns in the file. I am reading many files through Flink but file has string type column name and I am creating an model Object with the attributes as columns name available in file as below
DataSet<Person>> csvInput = env.readCsvFile("file:///path/to/my/textfile")
.pojoType(Person.class, "name", "age", "zipcode");
above code will ready file and Person object will be populated with the values available in the File.
I am facing challenge in new requirement where file columns name is numeric and in Java I cannot create a variable with numeric value along with decimal like -10.0 etc.
like private String -10.0 not allowed in java
I am seeking for a solution, could any one please help me out here.

Java example of joining 2 CSV files based on common column

I have 2 CSV file with the following content.
File 1
Id, Name, last name, city
1,peter,green,newyork
2,sam,red,londan
File 2
Id,Movie,Famous move
1,Hulk,punch
2,Ironman,taking the stone.
File after joining file1 and file2
File
Id, Name, last name, city,Movie,Famous move
1,peter,green,newyork,Hulk,punch
2,sam,red,london,Ironman,taking the stone
How I can join this 2 CSV file based on same column in java.
Any help will be appreciated.
Can anyone help how to achieve this in java. In python it is a 5 line code using PANDAS Lib.

How can I easily customize the XML input files of the Curriculum Course example of OptaPlanner?

I'm quite a beginner for not only OptaPlanner but also Java, which I started to learn two weeks ago. I am considering to start with modifying an example accompanied with the source program to make a scheduler for my present project.
Target
The XML input file of the “Curriculum Course” example of RedHat OptaPlanner
Question
Is there any easy way to modify the XML input files or add customized ones?
Example data
Original XML: optaplanner-examples/data/curriculumcourse/unsolved/comp01.xml
<CourseSchedule id="1">
...
<curriculumList id="27">
<Curriculum id="28">
<code>q000</code>
</Curriculum>
...
<courseList id="42">
<Course id="43">
<curriculumList id="44">
<Curriculum reference="28"/>
<Curriculum reference="30"/>
</curriculumList>
</Course>
...
</courseList>
...
</CourseSchedule>
The problem is that I have to renumber all the ID numbers every time I change the length of any lists.
In the “Curriculum Course” example, I can find the corresponding .ctt files that are easy to change using a common text editor. The following is input data that I want to create expressed in the .ctt format:
.ctt modified from: optaplanner-examples/data/curriculumcourse/import/comp01.ctt
Name: Test01
Courses: 3
Rooms: 3
Days: 5
Periods_per_day: 13
Curricula: 3
Constraints: 0
COURSES:
c0001 t000 5 99 1
c0002 t001 5 99 1
c0003 t002 5 99 1
ROOMS:
P01 999
P02 999
P03 999
CURRICULA:
q001 1 c0001
q002 1 c0002
q003 1 c0003
UNAVAILABILITY_CONSTRAINTS:
END.
I wonder some tools could convert this text data into the XML files specific to the “Curriculum Course” example.
If you click "Import..." button of the application, you can load the .ctt file and solve it. You don't need to convert .ctt to .xml. So there should be no problem for you to place your own xxx.ctt file under data/curriculumcourse/import and let the app import it.

Batch Inserts in PostgreSQL using JDBC

I want to insert a file into postgresql using JDBC.
I know the below command to use but the file downloaded is not parsed with a delimiter("|" or ",")
Filereader fr = new FileReader("mesowest.out.txt");
cm.copyIn("COPY tablename FROM STDIN WITH DELIMITER '|'", fr);
My file looks like this :
ABAUT 20131011/0300 8.00 37.84 -109.46 3453.00 21.47 8.33 241.90
ALTU1 20131011/0300 8.00 37.44 -112.48 2146.00 -9999.00 -9999.00 -9999.00
BDGER 20131011/0300 8.00 39.34 -108.94 1529.00 43.40 0.34 271.30
BULLF 20131011/0300 8.00 37.52 -110.73 1128.00 56.43 8.07 197.50
CAIUT 20131011/0300 8.00 38.35 -110.95 1381.00 54.88 8.24 250.00
CCD 20131011/0300 8.00 40.69 -111.59 2743.00 27.94 8.68 285.40
So my question is .. is it necessary to append delimiters to this file to push it into the database using jdbc?
from postgres documentation
delimiter : The single character that separates columns within each row (line) of the file. The default is a tab character in text mode, a comma in CSV mode.
It looks like your data is tab delimeted. So using the default should work.
Filereader fr = new FileReader("mesowest.out.txt");
cm.copyIn("COPY tablename FROM STDIN", fr);
You need to transform your file in some way, yes.
It looks it is currently either delimited by a variable number of spaces, or it has fixed width fields. The difference being, what would happen if 2146.00 were changed to 312146.00? Would it run into the previous field like "-112.48312146.00", like fixed width would, or would you add a space anyway even though that would break the column alignment?
I don't believe either of those are directly supported by COPY, so some transformation is necessary. Also, -9999.00 looks like a magic value that should probably be converted to NULL.

Extracting a column from a paragraph from a csv file using java

MAJOR ACC NO,MINOR ACC NO,STD CODE,TEL NO,DIST CODE
7452145,723456, 01,4213036,AAA
7254287,7863265, 01,2121920,AAA
FRUNDTE,FMACNO,FACCNO,FDISTCOD,FBILSEQ,FOOCTYP,FOOCDES,FOOCAMT,FSTD,FTELNO,FNORECON,FXFRACCN,FLANGIND,CUR
12345,71234,7643234,AAA,001,DX,WLR Promotion - Insitu /Pre-Cabled PSTN Connection,-37.87,,,0,,E,EUR
FRUNDTE,FMACNO,FACCNO,FDISTCOD,FBILSEQ,FORDNO,FREF,FCHGDES,FCHGAMT,CUR,FORENFRM,FORENTO
3242241,72349489,2345352,AAA,001,30234843P ,1,NEW CONNECTION - PRECABLED CHARGE,37.87,EUR,2123422,201201234
12123471,7618412389,76333232,AAA,001,3123443P ,2,BROKEN PERIOD RENTAL,5.40,EUR,201234523,20123601
I have a csv file something like the one above and I want to extract certain columns from it. For example I want to extract the first column of the first paragraph. I'm kind of new to java but I am able to read the file but I want to extract certain columns from different paragraphs. Any help will be appreciated.

Categories