I would like create a dynamic Pivot table in Java and I have code snippet in PERL. I would like to use the same process to create this dynamic pivot table in Excel.
I a dealing with Json response and I have limited knowledge in Java hence need help on Code perspective.
I have tried to use the HASHMAP to imitate
++$pivot{$app}{$device}{$browser}; but I am not able to do the same.
I need to produce the same like below in Java.
APP 1 AAP 2 APP3 App4
Device 1 7 92 53 9
Browser 1 7 54 39 7
Browser 2 10 4
Browser 3 1 1
Device 2 1
Browser 1
Browser 2
Browser 3
Device 3 1
Browser 1
Browser 2
Browser 3
Grand Total
$app = $responseapps5[$k];
$device = $responseclientdevice[$k];
$browser = $responseclientbrowser[$k];
$userid = $responseid[$k];
++$pivot{$app}{$device}{$browser};
++$pivot{$app}{'TOTAL'}{$browser};
++$pivot{$app}{'TOTAL'}{'TOTAL'};
++$pivot{$app}{$device}{'TOTAL'};
++$pivot{'TOTAL'}{$device}{$browser};
#++$pivot{$app}{$browser};
++$categ{'device'}{$device};
++$categ{'browser'}{$browser};
++$app{$app};
$row1++;
#print Dumper $app;
Related
I have data in Stata regarding the feeling of the current situation. There are seven types of feeling. The data is stored in the following format (note that the data type is a string, and one person can respond to more than 1 answer)
feeling
4,7
1,3,4
2,5,6,7
1,2,3,4,5,6,7
Since the data is a string, I tried to separate it by
split feeling, parse (,)
and I got the result
feeling1
feeling2
feeling3
feeling4
feeling5
feeling6
feeling7
4
7
1
3
4
2
5
6
7
1
2
3
4
5
6
7
However, this is not the result I want. which is that the representative number of feelings should go into the correct variable. For instance.
feeling1
feeling2
feeling3
feeling4
feeling5
feeling6
feeling7
4
7
1
3
4
2
5
6
7
1
2
3
4
5
6
7
I am not sure if there is any built-in command or function for this kind of problem. I am thinking about using forval in looping through every value in each variable and try to juggle it around into the correct variable.
A loop over the distinct values would be enough here. I give your example in a form explained in the Stata tag wiki as more helpful and then give code to get the variables you want as numeric variables.
* Example generated by -dataex-. For more info, type help dataex
clear
input str13 feeling
"4,7"
"1,3,4"
"2,5,6,7"
"1,2,3,4,5,6,7"
end
forval j = 1/7 {
gen wanted`j' = `j' if strpos(feeling, "`j'")
gen better`j' = strpos(feeling, "`j'") > 0
}
l feeling wanted1-better3
+---------------------------------------------------------------------------+
| feeling wanted1 better1 wanted2 better2 wanted3 better3 |
|---------------------------------------------------------------------------|
1. | 4,7 . 0 . 0 . 0 |
2. | 1,3,4 1 1 . 0 3 1 |
3. | 2,5,6,7 . 0 2 1 . 0 |
4. | 1,2,3,4,5,6,7 1 1 2 1 3 1 |
+---------------------------------------------------------------------------+
If you wanted a string result that would be yielded by
gen wanted`j' = "`j'" if strpos(feeling, "`j'")
Had the number of feelings been 10 or more you would have needed more careful code as for example a search for "1" would find it within "10".
Indicator (some say dummy) variables with distinct values 1 or 0 are immensely more valuable for most analysis of this kind of data.
Note Stata-related sources such as
this FAQ
this paper
and this paper.
I have a data form where I want one button to be able to add multiple rows of data to a SharPoint List. The list looks like this:
Batch | Part | Date | Time | Test | Result
The issue is that there 5 tests per Batch and Part combination. I want one input field for the Batch, Part, Date, and Time. Then I want 5 fields for the Test Number and 5 fields for the results. Once clicking the Submit button, the data would like like this:
Batch | Part | Date | Time | Test | Result
1 1 1/1/19 30 1 10
1 1 1/1/19 30 2 11
1 1 1/1/19 30 3 10
1 1 1/1/19 30 4 15
1 1 1/1/19 30 5 19
I know I can have the user put in the Test and Result, Submit, and then only reset those fields. I would like to be able to Submit all data at once instead of needing to press Submit 5 times.
You can save those 5 records is a collection, and then patch all the collection to your sharepoint list.
To patch all rows of a collection:
ForAll(CollectionName, Patch(SharePoint_ListName, Defaults(SharePoint_ListName), { ColumnName1: value1, ColumnName2: value2, etc})
Where ColumnName1 is the name of the column in your sharepoint list, and value1 is the name of the column in your collection.
I have a table with approximately 4.7 million records. I created a full text index on it.
I am experiencing slow initial population of the full text index.
Initial pricing tier that i had was S1, I upgraded it to S3 but i did not get better performance.
DTU and CPU are not high (usually staying around 0% ), the current velocity is about 175000 records per hour.
What can i do to speed this up?
Thanks in advance.
LE.
I tried same operation on a local instalation of SQL Server 2014, i had no problems with indexing the data.
Update 14.11.2016
Output to dm_Exec_requests
session_id request_id start_time status command sql_handle statement_start_offset statement_end_offset plan_handle database_id user_id connection_id blocking_session_id wait_type wait_time last_wait_type wait_resource open_transaction_count open_resultset_count transaction_id context_info percent_complete estimated_completion_time cpu_time total_elapsed_time scheduler_id task_address reads writes logical_reads text_size language date_format date_first quoted_identifier arithabort ansi_null_dflt_on ansi_defaults ansi_warnings ansi_padding ansi_nulls concat_null_yields_null transaction_isolation_level lock_timeout deadlock_priority row_count prev_error nest_level granted_query_memory executing_managed_code group_id query_hash query_plan_hash statement_sql_handle statement_context_id dop parallel_worker_count external_script_request_id
90 0 57:45.2 running SELECT 0x020000004D4F6005A3E8119F3DD3297095832ABE63E312F20000000000000000000000000000000000000000 0 66 0x060005004D4F6005D04F998A6E00000001000000000000000000000000000000000000000000000000000000 5 1 70A61674-396D-47EB-82C7-F3C13DAA2AD0 0 NULL 0 MEMORY_ALLOCATION_EXT 0 1 141037 0x380035003100450039003200350032002D0045003700450032002D0034003600320041002D0039004200390041002D003200310037004400300036003700430032004100360039 0 0 1 1 0 0x7A218C885C2F7437 0 0 228 2147483647 us_english mdy 7 1 1 1 0 1 1 1 1 2 -1 0 1 0 0 0 0 2000000026 0xC1681A4180C2C052 0x63AD167562BDAE5D 0x0900A3E8119F3DD3297095832ABE63E312F20000000000000000000000000000000000000000000000000000 7 1 NULL NULL
As i can see on P1 this seems much faster though. It is strange because it is not much more powerfull than S3.
I will mark it as solved because, it seems this is an issue related to service tier levels.
If you bump up the service tier of Azure database the full text indexing will run much faster than at standard level.
I could not sense a diference between S1 and S3, but P1 versus S3 is much faster.
I do not know the resoning behind this, even though the diference in DTU's is only 25 (S3: 100 DTU, P1: 125 DTU )
iam loading data in to GemfireXD from a file ....
file contain the information like this...
ID NAME
1 |John Smth
2 |Jane
3 |Paul Joes
4 |Mark Jcobs
5 |Mary Sphenson
6 |Steve oberts
7 |Margaret Johnso
AFTER LOADING THE DATA IN TO GemfireXD ,if you fire query SELECT * FROM TABLE Output is like this ....
ID NAME
5 |Mary Sphenson
7 |Margaret Johnso
4 |Mark Jcobs
2 |Jane
3 |Paul Joes
1 |John Smth
6 |Steve oberts
many i know the reason why the ID are notstored in a proper order like INPUT File
help on this....
Thanku You
Well, this has nothing to do with GemFireXD as such but basic SQL. Results of a select are not required to be ordered unless you specify an "order by" clause. Add "order by".
I have a following shell script
RETVAL=`sqlplus -silent user/password <<EOF
SET PAGESIZE 9990
SELECT id, type, count(*) "count" FROM event
EXIT;
EOF`
echo $RETVAL
it output like
ID TYPE count ------------- ---------- ----------- 2 11 2 1 4 1 2 10 29 1 1 35 2 1 6 2 18 1 2 2 3 7 rows selected
But i want output like
ID TYPE count
------------- ---------- -----------
2 11 2
1 4 1
2 10 29
1 1 35
2 1 6
2 18 1
2 2 3
7 rows selected.
I tried to figure out if i get some new line character but couldnt find it.
Regards,
Your variable contains the newlines, but the way you're displaying it removes them.
Replace the echo statement with:
echo "$RETVAL"
The shell won't mess with the newlines then. You should pretty much always quote variables that can contain any form of whitespace that needs to be preserved.