Author Topic: Data list manipulation  (Read 5558 times)

0 Members and 1 Guest are viewing this topic.

noadea

  • Guest
Data list manipulation
« on: April 16, 2007, 05:49:21 AM »
Hi All,
I have a problem to manipulate the data list. Here are example of data in csv format:
1   1
2   -
3   -
4   -
5   4
6   5
7   6
8   -
9   7
10   8
11   -
12   -
13   10

From the data list, i suppose to draw line according to data by row. For better understanding, I attached the roughly drawing to describe my need. If refer to data square1 connect to circle1, square5 to circle4, square6 to circle5... But the problem here is the circles with "-" value in csv file. Example square2, square3 and square4 which connect to 3 different points between circle1 and circle4. How to get the  different points refer to the total of "-" at the time? (3 points between circle1 and circle4, 1 point between circle6 and circle7, 2 points between circle8 and circle10). Then the line should be drawn from square to point according to data in row. Thanks.



It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8785
  • AKA Daniel
Re: Data list manipulation
« Reply #1 on: April 16, 2007, 05:57:37 AM »
Got any code so we can see what you have so far?

noadea

  • Guest
Re: Data list manipulation
« Reply #2 on: April 16, 2007, 06:54:21 AM »
Here I attached the code that I  have for this moment.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Data list manipulation
« Reply #3 on: April 16, 2007, 07:18:05 AM »
For thoses interestd, here is the original thread:
http://forums.augi.com/showthread.php?t=58847
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

noadea

  • Guest
Re: Data list manipulation
« Reply #4 on: April 17, 2007, 03:06:28 AM »
This problem is outside of my programming level. I hope there are experts would help me solve this problem. Thank you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Data list manipulation
« Reply #5 on: April 17, 2007, 05:45:00 AM »
Where is the datalist for a sampling of squares and circle locations ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Data list manipulation
« Reply #6 on: April 17, 2007, 05:52:06 AM »
Is the connection pattern different each time ?

Do you have a sample csv file ?

Do you have a sample drawing file. ?

at least give us ALL the information.

How many of these are you doing. ?

Is it a school project ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

noadea

  • Guest
Re: Data list manipulation
« Reply #7 on: April 17, 2007, 07:30:28 AM »
Here are sample of drawing and csv file.
« Last Edit: April 17, 2007, 07:31:58 AM by noadea »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Data list manipulation
« Reply #8 on: April 17, 2007, 07:32:38 AM »
Good questions Kerry, I hope we get the answers.
I had very little time yesterday & less time today. :(
But here is what I started with. An assumption about the data list from the cvs file.
Then several hoops to get the data in a usable form.
I was about to replace the nil values according to the specifications when time ran out.
So here is what I have so far. Maybe tomorrow will be better for me. :?

Code: [Select]
(defun c:test ()
  ;;  given output from CVS file
  (setq output '("5,23,27,24"      "5,22,-,-"        "5,21,-,-"
                 "5,20,-,-"        "5,19,29,19.5"    "5,18,30,17.75"
                 "5,17,30,16.5"    "5,16,-,-"        "5,15,30,15"
                 "5,14,30,13"      "5,13,-,-"        "5,12,-,-"
                 "5,11,30,10"
                )
  )

  ;;===========================
  ;;  parser by CAB single character delim
  (defun sparser (str delim / ptr lst)
    (while (setq ptr (vl-string-search delim str))
      (setq lst (cons (substr str 1 ptr) lst))
      (setq str (substr str (+ ptr 2)))
    )
    (reverse (cons str lst))
  )
 
  ;; CAB 05/07/06
  ;;  group on the first two elements  A B of a flat list A B C D
  ;;  InpLst is the flat list ((A B) (C D) (E F)...)
  (defun group_on2 (InpLst / OutLst tmp grp idx sub)
    (while InpLst
      (setq OutLst (cons (list (car InpLst) (cadr InpLst)) OutLst))
      (setq InpLst (cddr InpLst))
    )
    (reverse OutLst)
  )


 
  ;; create a list of list with 4 items in each sub list
  (setq lst (apply 'append (mapcar '(lambda (x) (sparser x ",")) output)))
  ;;  convert to numbers
  (setq lst (mapcar '(lambda (x)(if (numberp (read x))(read x))) lst))
  ;;  group in pairs
  (setq lst (group_on2 (group_on2 lst)))
  ;;  Replace nil points
  ;| -=< Under Construction  >=-
  (setq idx 0)
  (while (< idx (length lst))
    (cond
      ((null stpt) (setq stpt (nth idx lst)))
      ((null (cadr (nth idx lst)))
      )
    )
  )
|;

 
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Data list manipulation
« Reply #9 on: April 17, 2007, 07:40:10 AM »
Oops, see there, I guessed wrong on the data. :-( The groups of 4 are reversed & there is an index number.
From CVS file:
Code: [Select]
("56,-,-0.62766,0.19281"
  "55,-,-0.71186,0.19281"   "54,-,-0.33241,0.69237"
  "53,-,-0.41661,0.69237"   "52,-,-0.50081,0.69237"
  "51,-,-0.83871,0.69237"   "50,-,-0.92291,0.69237"
......................
 )
Looks like this "56,-,-0.62766,0.19281" needs to be decoded to
 this  (0.19281  -0.62766)  (nil nil)   which are two points.
 
 Gotta go..
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

noadea

  • Guest
Re: Data list manipulation
« Reply #10 on: April 17, 2007, 09:52:29 AM »
FYI
Regarding to the data in csv file:
column A : number according to square
column B : number according to circle
column C : x-coordinate of square's centre point
column D : y-coordinate of square's centre point

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Data list manipulation
« Reply #11 on: April 17, 2007, 12:48:34 PM »
This does not match the drawing.
From the CVS file:
Code: [Select]
1   1    -1.4668   1.1332
 From the Drawing, Pad 1
Code: [Select]
                   BLOCK REFERENCE  Layer: "Pad"
                            Space: Model space
                   Color: 6 (magenta)    Linetype: "Continuous"
                   Handle = 326F
                  "GDM7211_VCO_TEST.Pad"
                at point, X=0'-8 9/16"  Y=0'-1 19/32"  Z=    0'-0"
                 X scale factor   1.00000
                 Y scale factor   1.00000
          rotation angle 0.0000
                 Z scale factor   1.00000
                 
Note that x = 8.5625   y = 1.59375
Why the discrepancy?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Fatty

  • Guest
Re: Data list manipulation
« Reply #12 on: April 17, 2007, 04:59:03 PM »
Alan, those coordinates are relative to
center of detail (to the crosshair)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Data list manipulation
« Reply #13 on: April 17, 2007, 05:09:30 PM »
Oh, thanks Fatty.
I never would have guessed. :?

So that means we are only interested in column A & B.
In the original post I thought the data file contained points for A & B but as we see now they contain text labels.

« Last Edit: April 17, 2007, 05:15:28 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Fatty

  • Guest
Re: Data list manipulation
« Reply #14 on: April 18, 2007, 08:23:38 AM »
Oh, thanks Fatty.
I never would have guessed. :?

So that means we are only interested in column A & B.
In the original post I thought the data file contained points for A & B but as we see now they contain text labels.


Alan,
I've tried to solve ir entire last weekend
with no luck
Perhaps my poor brain is not in the good
condition at the moment :-)

~'J'~