« first day    last day (2401 days later) » 

4:00 PM
nev mind, got it. had to wrap another SQL over it
 
JNK
oh subquery
 
JNK
don't use IN!
 
SELECT POLICY_NO,
FIRST_NAME,
CLASS_TYPE,
SUM(COALESCE(ILPREM, 0) + COALESCE(VLPREM, 0) +
COALESCE(LEGAL_DEF_AMT, 0)) OVER(PARTITION BY POLICY_NO, FIRST_NAME, CLASS_TYPE ORDER BY CLASS_TYPE, FIRST_NAME) "Risk_Premium"
FROM TEMP_CM_PHY_RISK_DATAMIG
 
JNK
oh so you made a field function
 
4:02 PM
yeah, needed to discard results where Risk_Premium = 0
 
JNK
@Josh really?
 
SELECT *
FROM (SELECT POLICY_NO,
FIRST_NAME,
CLASS_TYPE,
SUM(COALESCE(ILPREM, 0) + COALESCE(VLPREM, 0) +
COALESCE(LEGAL_DEF_AMT, 0)) OVER(PARTITION BY POLICY_NO, FIRST_NAME, CLASS_TYPE ORDER BY CLASS_TYPE, FIRST_NAME) "Risk_Premium"
FROM TEMP_CM_PHY_RISK_DATAMIG)

WHERE "Risk_Premium" = 0
 
:7807 I pressed the button @Sergio posted
 
any other way ?
 
Chat crashed right after
 
4:03 PM
:7813 where ? What button ?
 
posted in The Tavern of Insanity
DO NOT CLICK IT!!!!
1
Q: Chat offline pages show Stack Overflow.

C. RossThe maintenance pages for chat.meta.stackoverflow.com and chat.superuser.com show the Stack Overflow name and logo.

 
won't
what does it do ?
 
Apparently, it plays a Darth Vader noise and then breaks chat!
Anyway I am going to lunch. I'll be back later. @Ivo, you're in good hands!
 
well except for @Sathya ;-) j/k...
 
4:19 PM
I don't understand anything from the wikipedia article, but I get the point to have a field that identifies the parent in the child when I want to know which measurements belong to what dog
 
:7856 its like this.
you have a file, containing names of dogs and ids
(i'm talking about physicial files)
you have another file, containing the measurements of dogs
now how would you like the 2 files ?
you will need something in common.
we can take dog names, as the common field
but many dogs can have the same name
so we take the dog id.
now lets say the dog file has 100 entries
how will you find out what was dog #67's name and measurements ?
you will lookit up
fetch me details of dogs and measurements whose id is 67
in SQL it becomes
SELECT * FROM DOGS WHERE ID=67
Now from your tables I see that measurements table does not have a link to the dogs table
 
I edited it to both include dogid
 
OK, so to fetch data from meausements
SELECT * FROM MEASUREMENTS WHERE DOGID=67
Now, we have written 2 SQL statements.
since both the tables have a link, we can combine them
`SELECT * FROM DOGS
JOIN MEASUREMENTS ON DOGS.ID = MEASUREMENTS.DOGID
WHERE DOGS.ID =67`
so what this SQL does is
combines measurements table with dogs, using the common identifier of dog id
then filters and gets records of that dog whose id is 67
and then returns records
 
JNK
sathya
 
JNK
you would want select dogs.*, Measurements.* on your first line
 
JNK
4:34 PM
otherwise no point in joining measurements
 
:7909 Hmm, seems to work fine on Oracle
 
JNK
and i think do a right join so you get all measurement records for each dog, right?
 
JNK
orly!
 
JNK
is it returning data from measurements too?
 
it's inner join
 
JNK
4:35 PM
ok
 
well two problems: I don't have the dogs in the database yet (easy part) and can't figure out how to get an array in there
 
JNK
but it auto selects fields in your joined table in oracle?
 
:7918 yes
 
JNK
nice
 
JNK
i think sql server would return * from DOGS, but limit the records based on the join condition
 
4:37 PM
:7922 ooo
 
JNK
maybe not though, i try never to use select *
 
In oracle inner join is assumed and returns it implicitly
and tbh I kinda that that join x on y syntax
 
I'll go watch a video on showmedo on this topic and get back to you guys after that ;-)
 
I always use where x-y
:7927 sure
 
JNK
ok @IvoFlipse
 
JNK
4:38 PM
good lucj
 
:7927 link me to your array file of 1 dog
 
I'm already angry for every example to just use strings or integers :@
 
I'll have a look in evening
:7933 just replace with what you don't like :)
 
well it doesn't seem to accept a whole array
 
tables are arrays :)
 
JNK
4:40 PM
im betting you will need to feed it one element at a time
 
the downside of working with databases is that you fail miserably while grasping concepts of fetching data frm flat files :-\
 
JNK
actually i do flat files a lot
 
JNK
main part of my job is mapping very large flat files to sql
 
JNK
very very large ones
 
well that SO answer @JNK linked at least showed how to split my 3D array into 2D's so they can be written to text files
 
JNK
4:44 PM
one client sends around 33 GB of text files a month
 
JNK
@IvoFlipse good!
 
woot, that's large
 
JNK
once you get it into SQL it will be easy
 
well @JNK that SO question was asked by me :P
 
JNK
i know
 
JNK
4:45 PM
thats why i linked it
 
ah ok :)
 
JNK
it was for @Josh
 
:7942 That's the easy part.
 
JNK
he was asking what kind of data you had so i posted those links
 
I'm talking about via a program
 
4:46 PM
ah but it's in the middle of my question too
 
JNK
oh screw that sathya
 
@JNK
 
JNK
Sorry, we are unable to scan this file for viruses.
 
JNK
NICE TRY!
 
they're having problems it says @Sathya
 
JNK
4:47 PM
hes trying to infect us
 
eheh
 
JNK
it's the old "hang around a Q&A site for a year to get reputable then give two people a virus once they trust you" con, the oldest one in the book!
2
 
ah yes,
my master plan has been foiled
BUT I SHALL NOT ACCEPT DEFEAT! I SHAL CONKEUR YOU ALL!! ALL I SAY!! MUHUHAHAHAHA
 
JNK
This webpage has a redirect loop.
 
JNK
4:50 PM
:(
 
recursion, still?
 
JNK
its a redirect loop
 
JNK
more like recursion, STILL
 
JNK
:7970 click on that
 
that better :P
 
4:52 PM
googles recursion did you mean recursion? clicks on recursion did you mean recursion? clicks on recursion did you mean recursion? clicks on recursion
 
JNK
exactly
 
JNK
still broke
 
:?
 
? what's broken
 
4:54 PM
you signed in to Google ?
 
JNK
i am
 
:8006 the link to the image, apparently for @JNK
 
JNK
oh now it shows
 
JNK
original dog name
 
no image here for me either...?
 
4:56 PM
:/
ok, hold on
 
can see that on
 
so what do I do with a 3D array?
store each frame as a flatted 2D array?
that almost makes it sound like it's easier to just parse the file again when I need it :P
 
JNK
@IvoFlipse parse it out as a string would be easiest
 
argh I had enough trouble parsing the file and now your telling me to reverse all my work :P
I knew just enough how to split it up nicely, I wouldn't know how to split the string again afterwards
 
JNK
@IvoFlipse was just messing with you, no worries
 
5:04 PM
at least it would allow me to ask it on SO :P
 
JNK
I have no IDEA what the best way to get it into sql will be
 
JNK
once you get it in there i can help you
 
no I know you're right, but it just sucks
I'm constantly reaching over the borders of my programming knowledge
 
JNK
i am too but i have pretty narrow borders :)
 
5:18 PM
I just had a great idea, first let's see whether I'm actually able to read all the measurements without trouble and see what that gives me
plus I still think I need to create classes to manage everything, though I could get away with NOT doing it if I wrote everything to a database after processing it
 
JNK
i think youll be able to do a lot of cool stuff once its in the DB
 
how do you turn off the beep?
ah got it the beep off
 
@barlop click on speaker next to all rooms link
 
ta
 
6:03 PM
well @JNK at least I can read all the files and create a nice image out of them
so if I store those to a DB at the end of my script, at least I solved part of my problem
 
JNK
@IvoFlipse purty!
 
6:15 PM
time to start writing a SO question I guess
 
JNK
well what are you after?
 
JNK
translating 3d array into a DB in python?
 
pretty much
 
JNK
ok post away :)
 
well that image is blocked so all I see are grey diagonal lines :/
 
6:18 PM
well I could make a subplot with less images :P
 
well it wouldn;t matter
it would still be blocked
 
but at least it would be larger in here :P
 
heh
 
this one should already be larger too
oh not for you too bad!
 
JNK
looks same to me ivo
 
JNK
6:21 PM
preview is same, file is bigger when i follow link
 
yeah, that was my point, just hoped it would be larger in here too
 
6:35 PM
:7955 Sorry I was at lunch
What was for me? You have cookies??
 
anyone mention cookies ?
oh yeah @Josh GIMME TEH COOKIEEZZZ
 
:8124 DO WANT!
 
JNK
so confused
 
:8126 LOL. I was at lunch, and you said
 
JNK
oh
 
JNK
6:37 PM
the links i posted of ivo's SO questions
 
Oh, right. I did see those before I left. Thanks :-)
How's the database coming @Ivo?
 
so well, I'm now asking a SO question :P
 
post the link when done
 
will do :)
 
Good :-)
 
Tom
6:56 PM
So if I understand it correctly, this room is for asking questions about programming? like if I want to know how to initialize an array in VB.Net?
 
:8148 basic stuff
More advanced, SO type stuff should go to:
That room will be moved/recreated on chat.stackoverflow.com after that 3rd place goes live
 
Dim <array_variable_name>(<length>) as <type>
@Tom
 
Tom
ty
 
Wow I forgot about Dim, haven't used VB in like 15 years, LOL
 
:8159 LOL, been like 5-years I guess
 
7:16 PM
shoot:
6
Q: How to insert arrays into a database?

Ivo FlipseIn my previous question a lot of users wanted me to give some more data to toy with. So I got working on exporting all my data and processing it with Python, but then I realized: where do I leave all this data? Well I decided the best thing would be to stick them in a database, so at least I do...

 
:8188 How fast can my fingers go!?!?!
I doubt I can answer in time... :-)
 
probably they want a sample as well, best I add it in
next to the raw data that is
oh wait, those files are too large :(
 
So when you say
> 3D array (250 frames of the whole plate)
you mean 250 integers?
 
no, 250 * an array of 255*63 sensors (counting from 0)
 
wow, OK
I'm probably cheating by asking you to clarify here, but.. :-)
 
7:26 PM
well it's very small compressed (thanks for the reminder @Sathya), but 16 Mb uncompressed
I edited the question
 
Thanks. I'm 50% done with my answer, no other answers yet, whew!
 
I should put my script (as far as I have edited it) on my blog, so people can try it themselves if they feel like it
 
250 frames... 63 sensors...
what's the 255?
in Fake Programmers on Super User Chat, Sep 17 at 19:24, by Ivo Flipse
no, 250 * an array of 255*63 sensors (counting from 0)
the value?
 
no it's a grid/matrix of sensors
so it's 256 sensors long, 64 sensors wide
measuring for 248 frames (I just rounded it up)
 
oh Ok, editing answer
4
A: How to insert arrays into a database?

JoshYou'll probably want to start out with a dogs table containing all the flat (non array) data for each dog, things which each dog has one of, like a name, a sex, and an age: CREATE TABLE `dogs` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(64), `age` INT UNSIGNED, ...

Does that make any sense? :-)
 
7:36 PM
I'm trying it out now
though the first thing it says when I try the CREATE TABLE 'dogs'
is going: syntax error behind the table :S
well his point is quite valid, why would I want to dump it if it's so much work rebuilding it
but you can't go building software with separate txt files
 
you might want to add column indicating which paw the data is for
 
hm, ok, that's a differentce between MySQL (which my code is) and sqlite (which you're using :-)
:8222 Duuurrrh, yeah
 
well if I could get it working with mysql I wouldn't mind trying it :P
 
CREATE TABLE `dog_measurements` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `dog_id` INT UNSIGNED NOT NULL,
  `paw` ENUM ('Front Left','Front Right','Rear Left','Rear Right'),
  `taken_at` DATETIME NOT NULL
);
:8225 I'm googling sqlite syntax :-)
did you actually use: CREATE TABLE 'dogs'
or did you use `dogs`
 
'dogs'
on the tutorial I read it was something like:
 
7:41 PM
with MySQL, you use ' or srings and ` for tables
 
its ' '
well actually
 
sql = """CREATE TABLE Settings (id INTEGER PRIMARY KEY AUTOINCREMENT,
setting TEXT,
value TEXT)
"""
 
I don't think you need either
just CREATE TABLE DOGS <BLEH> should do
 
:8237 Yeah, try ignoring all my `s
I insert those out of habbit
 
sql = """CREATE TABLE 'dogs' (id INT UNSIGNED NOT NULL PRIMARY KEY,
... name VARCHAR(64), age INT UNSIGNED)""" works
 
7:44 PM
sweet
 
had to remove the auto increment (perhaps its the _ in it) and the sex 'male' gives and error :S
 
I'm confused :-s
the create table is a one time thing
why do you need to add it to your program
 
:8242 Maybe sqlite doesn't support AUTO_INCREMENT?
The point of auto increment is so that you can INSERT new rows, and the id column will be automatically generated for you. For creating new dogs
And @Sathya is correct, the tables should just be created once, then you INSERT INTO them
 
for sqlite autocrement a field just needs to be INTEGER PRIMARY KEY (from: sqlite.org/faq.html#q1)
 
yeah, but part of the question off course was designing the right database and then inserting them
your point would be: use some sort of lookup table where every value is stored in it's own field?
This should have been a comment but it's a response towards your answer @Josh:
> The only thing I would add to Josh's answer is that if you don't need to query individual frames or sensors, just store the arrays as BLOBs in the dog_measurement_data table. I have done this before with large binary set of sensor data and it worked out well. You basically query the 2d and 3d arrays with each measurement and manipulate them in code instead of the database.
 
7:50 PM
:8253 Yeah, well...
I'll respond on SO and quote here :-)
 
I'm keeping my eye out for my question, so no need to response in two places :)
 
Cool
 
is secretly enjoying that Super Users will drive @IvoFlipse crazy
 
you always drive me crazy, even without my questions :P
 
JNK
@Sathya if you type your thoughts into a logged chat room they are no longer secret
2
 
7:54 PM
:8261 hahha ! yay! :P
 
I find it amusing how the answer "I think you are not able to figure out how to put 2D data in database." is more upvoted than my 45-minute answer, haha
 
not anymore :)
 
JNK
@Josh fixed
 
JNK
sathya and JNK to the rescue
 
just a minor typo: dog_measurement_id,frame,sensor_row,sensor_col`,value
' missing there (according to the markdown)
 
7:57 PM
:8267 Ha! Thanks guys :-)
:8271 sure is, fixing
 
for: That way, for each of the 250 frames, you loop through each of the 63 sensors, and store the value for that sensor with the frame number into the database:
 

« first day    last day (2401 days later) »