Regarding CSV import in Drupal 7 - drupal

I have a csv file like 3*3 like 3 row and 3 column like this
value1 value2 value3
value1 value2 value3
value1 value2 value3
and a table with 3 coulmns like
column1 column2 column3
how can I programmatically import the CSV data in database and want to show in other page also.. So how to achieve this.

If from table you mean you have content type, you can use feeds module to import csv and map with the content type fields.

Related

Read / Import specific rows from large Excel files in R

I have dozens of very heavy Excel files that I need to import into R (then rebind). Each file has 2 sheets, where the second sheet (name: "Results") consists of 100K rows at least and has about 350 columns.
I would like to read a subset of the sheet "Results" from each file by columns, but most importantly, by specific rows. Each "ID" in the data, has a main row and then multiple rows below which contain data in specific columns. I would like to read the main row only (this leaves each file with 50-400 rows (depending on the file) and 150 variables). The first column that numbers main rows does not have a header.
This is what the data looks like (simplified):
I would like to import only the rows whose first column isn't empty but numbered (i.e., 1., 13., 34., 211.) and particular columns, in this example columns 2,3,5 (i.e., name, ID, status). The desired output would be:
Is there a simple way to do this?
Let's say a is our excel file, as data frame.
library(readxl)
a <- as.data.frame(read_excel("Pattern/File.xlsx",sheet = "Results"))
For instance, we want to select columns 1 to 3, so use
subset(a[,1:3],is.na(a[1])==FALSE)
By this function, you are subsetting the input data frame with values different than NA in first column.
Output:
...1 name ID
1 1 Dan us1d
4 13 Nev sa2e
6 34 Sam il5a
Note first column name (" ...1 "). This is autogenerated by read_excel() function, but should not be a problem.

SQLite: How can I copy data from a column in table 1 and paste the data on a column of table 2 according to IDs of the data in specific rows?

In TABLE 1 (LEFT SIDED), I have lists of words in a column(WordEng) and each of them have unique IDs listed parallel in another column(WordEngID).
In TABLE 2 (RIGHT SIDED), I have lists of word IDs, which is nothing but unique IDs of words in TABLE 1. I want to copy words from TABLE 1 into a column in TABLE 2 according to its unique IDs. In Table 1 no words have same IDs and in Table 2 the same IDs are in different rows.
For example,
there is a word "cut" with ID "1807" in Table 1 and I want to copy and paste it in the column "words" in Table 2 which have IDs "1807"(five in this case).
You need this UPDATE statement:
UPDATE Table2
SET words = (SELECT t1.WrdEng FROM Table1 t1 WHERE t1.WrdEngId = Table2.WrdEngId)
WHERE words IS NULL
If you want all the values of words updated, even if they are not null, then remove the WHERE clause.

In R: addDataFrame Excel package function

When I create an Excel workbook using addDataFrame function to add my dataset, then I get automatically an extra column displayed in Excel which indeed count the number of observations of the dataset.
Let say my dataset is 1 column dataset as:
My1stCol: val1 val2 val3
Then in Excel I'll get 2 columns:
The extra column added with values: 1 2 3
My1stCol: val1 val2 val3
How can I get rid of the automatically added column 1,2,3 information in excel that I don't need ?
Looking forward to your reply

Adding date from 3 columns in table X to one column in table Y

Hi I am new to sqlite and I am wondering if it is possible to add date from 3 columns in table X to one column in table Y. For example, in Table X, I have 3 columns called startDay,startMonth,startYear. I want to add these to one column in table Y called Start_Date (possible in format DD/MM/YYYY). Also hopefully the format it is in should be able to carry out computation, i.e subtracting 2 dates. Any ideas?
You can do something like:
CREATE TABLE newtable(start_date TEXT);
INSERT INTO newtable
SELECT printf('%d-%02d-%02d', startYear, startMonth, startDay)
FROM oldtable;
And to compute the number of days between two dates:
SELECT juliandate('2019-06-30') - juliandate('2019-06-29') AS diff;
diff
----------
1.0
(Using a format other than those supported by sqlite date and time functions like your dd/mm/yyyy is a bad idea. Means you can't use them with the functions, and in your case, also means you can't meaningfully sort by date)

Reading in R depending upon header

I have a question about R. If I havr a date like this
# name : Matrix
col1. col2
row1
row2
How can read the name of the subset of data from header and make a frame of same name in R. So that I can use it by the name Matrix.
And if I needed to read number of rows as specified in the header. What should I do. For example if this was the header, I would like to read 2 columns and 2 rows and name this frame Matrix
# name : Matrix
# row: 2
# col: 2
col1. col2
row1
row2
Thank you all.

Resources