[Solved] spread sin...
 
Notifications
Clear all

[Solved] spread single key against multiple values

0 Posts
1 Users
0 Likes
5 Views
0
Topic starter
ks ramana Asks: spread single key against multiple values
I have data frame as follows: Actual data runs into hundreds of rows and columns

The objective here is to spread "Attribute Value" against each of the column V1, V2,...VN. That is dates that are appearing in column V1, should get spread into column names And corresponding "Attribute Value" should appear against each below

Code:
              df1 <- data.frame(ROW_ID = c("23416","23416","23416"),
              Process_ID = c("SLT","SLT","SLT"),
              Operation_Code = c("SLT","SLT","SLT"),
              Resource_Group_Code = c("BD","BD","BT"),
              Location_Code = c("JS","JS","JS"),
              Resource_Code = c("B-T234","B-T234","B-T234"),
              Resource_Desc = c("699","699","699"),
              iDeleteFlag = c("N","N","N"),
              Attribute_Code = c("RA002","RA002","RA002"),
              Attribute_Value = c("266","269","298"),
              Capacity_Type = c("s","s","s"),
              Planning_Version = c("PDMT","PDMT","PDMT"),
             "V1"= c("2021-10-10", "2021-10-31", "2021-11-07"),
             "V2"= c("2021-10-17", "", "2021-11-14"),
             "V3" = c("2021-10-24", "", "2021-11-21"),
             "V4" = c("", "2021-11-07", ""),
             "V5" = c("", "2021-11-21", ""))

The required output is as follows:

Code:
              df2 <- data.frame(ROW_ID = c("23416","23416","23416"),
              Process_ID = c("SLT","SLT","SLT"),
              Operation_Code = c("SLT","SLT","SLT"),
              Resource_Group_Code = c("BD","BD","BT"),
              Location_Code = c("JS","JS","JS"),
              Resource_Code = c("B-T234","B-T234","B-T234"),
              Resource_Desc = c("699","699","699"),
              iDeleteFlag = c("N","N","N"),
              Attribute_Code = c("RA002","RA002","RA002"),
                               Capacity_Type = c("s","s","s"),
              Planning_Version = c("PDMT","PDMT","PDMT"),
              "2021-10-10"= c("266", "", ""),
              "2021-10-17"= c("266", "", ""),
              "2021-10-24" = c("266", "", ""),
              "2021-10-31" = c("", "269", ""),
              "2021-11-07" = c("", "269", "298"),
              "2021-11-14" = c("", "", "298"),
              "2021-11-21" = c("", "269", "298"))

My code is as follows: my code not giving required output

Code:
                       RA002variable_2021ANeg <- gather(RA002variable_2021ANeg, key, value, - 
                       ROW_ID, - Process_ID, - Operation_Code, - Resource_Group_Code, -
                       Location_Code, - Resource_Code, - Resource_Desc, -
                       iDeleteFlag, - Attribute_Code1, - Capacity_Type, -
                       Planning_Version, -Attribute_Value) %>%
                       mutate(key =(  Attribute_Value)) %>%
                       select(- Attribute_Value) %>%
                       spread(key, value)

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

Unreplied Posts

[Solved] How to bind a variable in a snowflake create schema

RMC_DEV Asks: How to bind a variable in a snowflake create schema
I have a simple sql code I want to execute in my stored procedure
I am trying to bind the name of a schema but I am struggling to make it work
Below is my code

Code:
CREATE OR REPLACE PROCEDURE DATABASE.SCHEMA."CREATE_SCHEMA"("SCHNAME" VARCHAR(16777216))
RETURNS VARCHAR(16777216)
LANGUAGE JAVASCRIPT
COMMENT='Creates roles for new schemas'
EXECUTE AS CALLER
AS 
$$

    var sqlCode = "CREATE SCHEMA ?";  
    var statement = snowflake.createStatement({sqlText:sqlCode,binds:[SCHNAME]});  
    var result_set = statement.execute(); 

$$

When I bind variables in a select query for example, it works but I don’t know how to do it
in a statement above like CREATE
Any help would be greatly appreciated.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.
 
 
 

[Solved] How to read in values from a single line in a txt file

Aman Asks: How to read in values from a single line in a txt file
so I am trying to read and split the following data up into an array. However, the txt file only has one line.

1, 5, 3, 7, 9, 5, 3, 1, 9, 5, 7, 3, 7, 5, 9, 1, 3, 5

And I am not sure if I am correctly doing it with my code.

Code:
 try { 
      File cars = new File("cars.txt");
      Scanner myReader = new Scanner(cars);
      String data = myReader.nextLine();
      while (myReader.hasNextLine()) {
        data = myReader.nextLine();
        String values[] = data.split(",");
        System.out.print(values);
      }

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Activation Context Generation Failed for D:FolderNameappname.exe error in manifest or policy file

Sam Asks: Activation Context Generation Failed for D:FolderNameappname.exe error in manifest or policy file
I Have a windows application that uses another application to update its version files. In my main App , I saved the changed Dll and Exe files in my database and every time the main app runs , It calls updater app and updater app downloads the files and pastes them in the main app path (folder).

The downloading and pasting sections are working correctly .But when i want to execute the new replaced .exe file by shell method, It crashes.

Also when I want to run the new exe file manually, I see the following error: “The Application has failed to start because it’s side-by-side configuration is incorrect” .

After checking the event Log, I saw the following error: “Activation Context Generation Failed for D:FolderNameappname.exe error in manifest or policy file”

P.S.: When downloading and pasting are done by the main app, It works correctly

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Python beginner- syntax error: ‘break’ not properly in loop (for loop) [closed]

Gaurie Asks: Python beginner- syntax error: ‘break’ not properly in loop (for loop) [closed]
I’m trying to learn and understand how loops work and getting syntax errors (with both break and continue), I have tried changing indentation and changing where the print statements are written, but nothing is working and I’m confused as to why. my code is:

Code:
for item in range(1,6):
if item == 3:
  break
print(item)

I’m not sure what the issue is. it says “break outside loop” and I don’t understand what that means or how that could be.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Are all of the implicit type conversions that happen in JavaScript considered to be type coercion?

Steven Asks: Are all of the implicit type conversions that happen in JavaScript considered to be type coercion?
Say we have the following:

Code:
2 + "2"            // 2 will be converted to string

5 + true           // true will be converted to number

5 + new Number(1)  // new Number(1) (which is a Number) will be converted to number

"hello".length     // "hello" (which is a string) will be converted to String

All of the above examples involves implicit type conversions, but do all of the above examples considered to be type coercion, or only some of them considered to be type coercion?

More specifically, are all of the implicit type conversions that happen in JavaScript (and not just the ones that I showed in the above examples) considered to be type coercion?

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] SQL crystal report table hooking [closed]

Giuseppe Russo Asks: SQL crystal report table hooking [closed]
how can I hook an sql table to a report with ttx extension?

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Can you write a code in Java, which makes the txt file connection to a web server? [closed]

Joseph Smith Asks: Can you write a code in Java, which makes the txt file connection to a web server? [closed]
Please, can you write a code in Java, which makes the txt file connection to a web server?

Code:
ServerSocket serverSocket = new ServerSocket(port);
socket = serverSocket.accept();
InputStream is2= socket.getInputStream();

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Reading custom files on storage card for android sdk 30

erinys Asks: Reading custom files on storage card for android sdk 30
I have an app that creates custom files that are shown in a gallery. They are not images or other standard media files. Because the files are large, I ask users for access to a folder in which the files will be stored.

So far so good.

Reading those files or file info via DocumentFile is so much slower than via File. Operations like

Code:
DocumentsContract.findDocumentPath()
documentFile.isFile()
documentFile.getName()

take up to 15ms each, which accumulates to a large time when reading a large number of files.

What’s the best way to handle this? Is there another way to do this? I don’t want the files to be in internal app memory or users might lose their work when they uninstall the app.

Thanks in advance! This is stressing me out a lot.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] How do I start the Firebase Storage Emulator with production bucket data?

MarksASP Asks: How do I start the Firebase Storage Emulator with production bucket data?
I’m using the Firebase Emulator to run all Firebase services. I have managed to run the emulator with a backup of my Firestore data by running:

firebase emulators:start --import ./my-directory

… but I can’t find a way to do the same with my Storage data.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Find and manipulate array element in KSH

Shelby Anne Asks: Find and manipulate array element in KSH
I have an array that reads like this:

Code:
# echo "${ARRAY[@]}"
1=Napp Slice
4=NNN Issue
3=GG Allow
2=CO-OP
1=Quit

And I want to loop through it to see if any contain the word Quit and if so, set that element to a variable. So I ran below:

Code:
for x in ${ARRAY[@]}; do
  if [ $x == *Quit* ]; then
    FOO=$x
    echo $FOO
  else
    break
  fi
done

I want returned to me 1=Quit but when I run it I get:

Code:
# ./myScript.ksh
1=Napp Slice
4=NNN Issue
3=GG Allow
2=CO-OP
1=Quit

How can I pull out just the element containing Quit?

I really tried to see if this question existed before posting, I am newer to shell-scripting. I am sure there is something very simple that I am missing but I can’t seem to get it.

KSH syntax only please as that is all I have available to me.

Thank you!

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

Share: