How do I do when handling the data

  • Thread starter CatcherInTheRye
  • Start date
C

CatcherInTheRye

Hi, How are you.

I am a complete perl beginner.
So, now I don't know how to handle efficiently the raw data to any data
structure.


89 ;1;148;|89 ;2;316;|89 ;3;484;|45 ;1;142;|
45 ;1;142;|89 ;1;148;|33 ;2;258;| ; ; ;|
89 ;2;316;|89 ;3;484;|101;1;120;| ; ; ;|
89 ;3;484;|89 ;1;148;|89 ;2;316;|46 ;1;76 ;|
46 ;1;76 ;|67 ;2;248;|90 ;3;500;|33 ;2;258;|
33 ;2;258;|46 ;1;76 ;|45 ;1;142;|90 ;3;500;|
90 ;3;500;|91 ;3;372;|33 ;2;258;| ; ; ;|
91 ;3;372;|91 ;1;36 ;|42 ;3;446;|81 ;3;356;|
91 ;1;36 ;|101;1;120;|92 ;1;50 ;| ; ; ;|
92 ;1;50 ;|71 ;1;6 ;|72 ;3;370;|74 ;2;214;|
42 ;3;446;|42 ;1;110;|91 ;3;372;| ; ; ;|
101;1;120;|89 ;2;316;| ; ; ;| ; ; ;|

Raw data shown above.
I hope to check data validation each other data.
Let me show you the meaning of data.

"89 ;1;148" of first line is KEY and means CELL;SECTOR;PN
and has its neighbor list like "89 ;2;316;|89 ;3;484;|45 ;1;142;|"

Other line has same meaning.

I hope to code the script to process following conditions.

1. Don't have same PN in the same line. If there is , print "Same PN in
the '46 ;1;76 ' "
89 ;1;148;|89 ;2;316;|89 ;3;484;|45 ;1;142;|
* * * *
2. Second field "89 ;2;316;" should be existed in the line where "89
;2;316;" is key.
if there is not, print "89 ;1;148;" has "89 ;2;316;" but "89 ;2;316"
don't have "89 ;1;148;".
89 ;1;148;|89 ;2;316;|89 ;3;484;|45 ;1;142;|
+++++++++ *********
89 ;2;316;|89 ;1;149;|89 ;3;484;|101;1;120;|
********* +++++++++

Thanks in advance,
 
A

Anno Siegel

CatcherInTheRye said:
Hi, How are you.

I am a complete perl beginner.
So, now I don't know how to handle efficiently the raw data to any data
structure.


89 ;1;148;|89 ;2;316;|89 ;3;484;|45 ;1;142;|
45 ;1;142;|89 ;1;148;|33 ;2;258;| ; ; ;|
89 ;2;316;|89 ;3;484;|101;1;120;| ; ; ;|
89 ;3;484;|89 ;1;148;|89 ;2;316;|46 ;1;76 ;|
46 ;1;76 ;|67 ;2;248;|90 ;3;500;|33 ;2;258;|
33 ;2;258;|46 ;1;76 ;|45 ;1;142;|90 ;3;500;|
90 ;3;500;|91 ;3;372;|33 ;2;258;| ; ; ;|
91 ;3;372;|91 ;1;36 ;|42 ;3;446;|81 ;3;356;|
91 ;1;36 ;|101;1;120;|92 ;1;50 ;| ; ; ;|
92 ;1;50 ;|71 ;1;6 ;|72 ;3;370;|74 ;2;214;|
42 ;3;446;|42 ;1;110;|91 ;3;372;| ; ; ;|
101;1;120;|89 ;2;316;| ; ; ;| ; ; ;|

Raw data shown above.
I hope to check data validation each other data.
Let me show you the meaning of data.

"89 ;1;148" of first line is KEY and means CELL;SECTOR;PN
and has its neighbor list like "89 ;2;316;|89 ;3;484;|45 ;1;142;|"

What kind of explanation is that? What's a "CELL", what's a "SECTOR",
what's a "PN", in what sense can such triplets be "neighbors", how do
these terms relate to each other, and what does it mean when an entry
is blank (as happens in the third and fourth column)?

This opens more questions than it answers.
Other line has same meaning.

Oh, great!
I hope to code the script to process following conditions.

What code? What have you tried so far?
1. Don't have same PN in the same line. If there is , print "Same PN in
the '46 ;1;76 ' "
89 ;1;148;|89 ;2;316;|89 ;3;484;|45 ;1;142;|
* * * *
2. Second field "89 ;2;316;" should be existed in the line where "89
;2;316;" is key.
if there is not, print "89 ;1;148;" has "89 ;2;316;" but "89 ;2;316"
don't have "89 ;1;148;".
89 ;1;148;|89 ;2;316;|89 ;3;484;|45 ;1;142;|
+++++++++ *********
89 ;2;316;|89 ;1;149;|89 ;3;484;|101;1;120;|
********* +++++++++

We can help you with code you have, but we are not in the business
of writing programs to specification.

Anno
 
J

Jim Cochrane

We can help you with code you have, but we are not in the business
of writing programs to specification.

Anno

I suspect you would be if an appropriate fee were offered :)
 
G

gnari

CatcherInTheRye said:
Hi, How are you.

I am a complete perl beginner.
So, now I don't know how to handle efficiently the raw data to any data
structure.


89 ;1;148;|89 ;2;316;|89 ;3;484;|45 ;1;142;| [snip]

"89 ;1;148" of first line is KEY and means CELL;SECTOR;PN
and has its neighbor list like "89 ;2;316;|89 ;3;484;|45 ;1;142;|"

Other line has same meaning.

I hope to code the script to process following conditions.

1. Don't have same PN in the same line. If there is , print "Same PN in
the '46 ;1;76 ' "
89 ;1;148;|89 ;2;316;|89 ;3;484;|45 ;1;142;|
* * * *

if would use split() to split the lines into records
i would use a hash of Arrays to map each neighbour to the keys
I would use a split again or m// to extract the PNs of each line
and use a temporary hash to detect duplicates

2. Second field "89 ;2;316;" should be existed in the line where "89
;2;316;" is key.
if there is not, print "89 ;1;148;" has "89 ;2;316;" but "89 ;2;316"
don't have "89 ;1;148;".
89 ;1;148;|89 ;2;316;|89 ;3;484;|45 ;1;142;|
+++++++++ *********
89 ;2;316;|89 ;1;149;|89 ;3;484;|101;1;120;|
********* +++++++++

after all lines have been processes, I would loop over the keys
of the neighbour-hash to make sure all backreferences are there.

gnari
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top