w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Merging files (and file names) in R
You can just make a wrapper around the read.table() function that adds in your filename variable. Something like this should work: read.data <- function(file){ dat <- read.table(file,header=F,sep=",") dat$fname <- file return(dat) } Once there you just need to apply that function across your data files. Since you didn't post any example data I'm not sure what it actually looks like, but for now I'll assume it's clean as can be and that rbind() is sufficient to join them together, in which case this example should illustrate that function in action: > data(iris) > write.csv(iris,file="iris1.csv",row.names=F) > write.csv(iris,file="iris2.csv",row.names=F) > dataset <- do.call(rbind, lapply(list.files(pattern="csv$"),read.data)) > head(dataset) Sepal.Len

Categories : R

Create a 350000 column csv file by merging smaller csv files
This python script will do what you want: #!/usr/bin/env python2 import os import sys import codecs fhs = [] count = 0 for filename in sys.argv[1:]: fhs.append(codecs.open(filename,'r','utf-8')) count += 1 while count > 0: delim = '' for fh in fhs: line = fh.readline() if not line: count -= 1 line = '' sys.stdout.write(delim) delim = ',' sys.stdout.write(line.rstrip()) sys.stdout.write(' ') for fh in fhs: fh.close() Call it with all the CSV files you want to merge and it will print a new file to stdout. Note that you can't merge all files at once; for one, you can't pass 350,000 file names as arguments to a process and secondly, a process can only open 1024 files at once. So you'll have to

Categories : SQL

merging files based on column coordinates of two files in python
If it fits in memory, you can merge the two dataframes with an outer method base only on chrom column, then filter your result by doing the range inclusion math: df = snp.merge(gene, how='outer', on='chrom') df = df[(df.chromStart_x>=df.chromStart_y) & (df.chromEnd_x<=df.chromEnd_y)] You can eventually remove the duplicate columns: del test['chromStart_y'] del test['chromEnd_y']

Categories : Python

Merging 2 tables that contain duplicates
It sounds like you want to join the last record from r (based on jid) with the corresponding record from o. If so, then the following query would do what you want: select r.id, r.add, r.jid, r.sid, r.cocode, o.tid, o.date, o.cid from (select r.*, row_number() over (partition by id order by jid desc) as seqnum from r ) r join o on r.id = o.pkey and seqnum = 1;

Categories : SQL

merging records from two tables into third using SQL
Assuming table C is empty, then something like this would do the trick INSERT INTO C SELECT A.* FROM A LEFT OUTER JOIN B ON A.ID = B.ID WHERE (A.TIME1 > B.TIME1 OR B.TIME1 IS NULL) UNION SELECT B.* FROM B LEFT OUTER JOIN A ON B.ID = A.ID WHERE (A.TIME1 <= B.TIME1 OR A.ID IS NULL)

Categories : SQL

merging two tables with a query
You can "fuse" both results using a union like this SELECT Name, AGE FROM TABLE_A UNION SELECT Name, AGE FROM TABLE_B ORDER BY Name; The SQL statement selects all the different Names and Ages from the "TABLE_A" and the "TABLE_B" tables.

Categories : SQL

Merging two child tables from two different databases
First you need to be able to query both tables at the same time. You may need linked server or openrowset (or friends). Seeing as how you just want to merge child tables, the parent table is irrelevant. Then you need to figure out the logic of the merge. Let's say you want merge A into B. There are three types of situations: MATCHED NOT MATCHED [BY TARGET] NOT MATCHED BY SOURCE What do you want to do in each situation? After you have the design, the docs (http://technet.microsoft.com/en-us/library/bb510625.aspx) has very good examples. Basically you want: MERGE child as target USING (select ... from databaseA.dbo.child) as source (...) ON (conditions) WHEN MATCHED THEN UPDATE SET target.v = source.v WHEN NOT MATCHED BY TARGET THEN INSERT (v) VALUES (source.v) -- WHEN NO

Categories : Sql Server

Merging two tables in sqlite from different database
Okey first you have to attach the databases, to your current connection. SQLite give you this by using ATTACH. The ATTACH DATABASE statement adds another database file to the current database connection. ATTACH LINK Run this: attach database DatabaseA.db as DbA; attach database DatabaseB.db as DbB; Now you can reference the databases as you do with tables... select * from DbA.Table1 A inner join DbB.Table2 B on B.Emp_Id = A.Emp_Id; There is a limit to the number of databases that can be simultaneously attached to a single database connection. Check your settings if something goes wrong, the flag is: #define SQLITE_LIMIT_ATTACHED 7 // SQLITE_LIMIT_ATTACHED - The maximum number of attached databases.

Categories : SQL

Merging two tables using criteria with linq
Following query selects only prices with region 17 or null, groups them by unique key { p.product_type, p.product_size }. Then it checks whether group contain at least one price with region 17. If yes, then we select all prices of this region from group (and skipping prices with null region). Otherwise we return whole group (it has null regions only): var query = from p in PRICES.Where(x => x.region == 17 || x.region == null) group p by new { p.product_type, p.product_size } into g from pp in g.Any(x => x.region == 17) ? g.Where(x => x.region == 17) : g select pp; Input: 1 null 20 7 2.7 salad1 // goes to group {20,7} with region 17 price 2 null 20 3 2.5 salad7 // goes to group {20,3} without region 17 pric

Categories : C#

mysql merging two tables if not exist
You have to change NOT_IN in NOT IN, as this is the correct synthax INSERT INTO table1 (id, name) SELECT id, name FROM table2 WHERE table2.id NOT IN(SELECT id FROM table1);

Categories : Mysql

Problems with merging on-disk tables with millions of rows
The merged frame possibly will have no rows. Appending a len-zero frame is an error (though should be more imformative). Check the len before appending df = pd.merge(a, b , left_index=True, right_index=True,how='inner') if len(df): Atemp.append('mergev46', df) Results with your provided dataset <class 'pandas.io.pytables.HDFStore'> File path: var4.h5 /var4 frame_table (shape->1334) <class 'pandas.io.pytables.HDFStore'> File path: var6.h5 /var6 frame_table (shape->667) <class 'pandas.core.frame.DataFrame'> MultiIndex: 1334 entries, (928, 310, 2006001) to (1000, 238, 2006361) Data columns (total 1 columns): var4 1334 non-null values dtypes: float64(1) <class 'pandas.core.frame.DataFrame'> MultiIndex: 667 entries, (928, 310,

Categories : Python

create field merging info from other tables and fields
You can do what you want using update with join. Here is an example: update products p join localities l on p.localityid = l.locality id join categories c on p.categoryid = c.categoryid set p.title = concat(c.value, ' in locality ', l.value);

Categories : Mysql

How can I create a new table based on merging 2 tables without joining certain values?
INSERT INTO new_table SELECT * FROM (SELECT a.*, b.* FROM Consumers a INNER JOIN CustomerInfo b ON a.METER_NUMBER = b.METER and a.Location = b.Location WHERE a.METER_NUMBER IS NOT NULL AND a.METER_NUMBER <> 0 UNION ALL SELECT a.*, NULL as Meter, NULL as CustomerInfo_Location, NULL as Field2, NULL as Field3 FROM Consumers a WHERE a.METER_NUMBER IS NULL OR a.METER_NUMBER = 0 UNION ALL SELECT NULL as METER_NUMBER, NULL as Location, NULL as Field4, NULL as Field5, b.* FROM CustomerInfo b WHERE b.METER IS NULL OR b.METER = 0) c

Categories : SQL

SQL Merging Tables Based On Multiple Matching Column Values
My way would be to 1st: create a view for replacing rows and another with the correct result set that should be appended like --view for update create view ChangeTable1 as select table2.map, table2.authid,table2.name, table2.date, table1.map as t1map, table1.authid as t1authid...from table1 to inner join table2 on table1.map=table2.map and table1.athid=table2.autid where table1.time>table2.time -- view for appending create view Add2Table1 select table2.map, table2.authid,table2.name, table2.date... from table2 where concat(table2.map, table2.authid) not in (select concat(table1.map, table1.authid) from table1) -- update statement based on first view ChangeTable1 update ChangeTable1 set t1date=date, t1somevalue=somevalue...... -- insert Statement based an second view Add2Table1 i

Categories : Mysql

Git merging does not delete files
I'm not sure you've originally added the files to branch A. branch A does create a branch called A, but you still remain on your original branch, where you added the files. git checkout -b A creates branch A and checks it out immediately.

Categories : GIT

Merging XML files using python
take a look at lxml http://lxml.de/index.html It's a great librarie that features everything you need to accomplish this. You'll have to parse both files and then use xpath to search for the right content in one file and copy it into the right element in the other file. I'm not going to code the whole thing for you but if you have trouble with specific steps in your code, we'll be happy to help :)

Categories : Python

merging of Netcdf files
NCO's ncecat can combine any number of netCDF files together with ncecat in1.nc in2.nc ... inN.nc out.nc Switches and other options are described in the documentation

Categories : Csv

Merging multiple XML files in Java
Here's a simple merge, in which all children of the root node in one document get appended to the root node of a second document: public static void mergeSecondLevel(Document from, Document to) { Element fromRoot = from.getDocumentElement(); Element toRoot = to.getDocumentElement(); Node child = null; while ((child = fromRoot.getFirstChild()) != null) { to.adoptNode(child); toRoot.appendChild(child); } } If you're trying to do some sort of processing on the nodes before merging them (you say some attributes should be summed), then this won't be sufficient. There's a linked post that covers using XPath to retrieve nodes, but even then you're going to have to write logic to ensure the correct updates.

Categories : Java

How to read 2 files together in Mule for merging
I can think of two options: Configure the file inbound endpoint to select say the XML files and in your component use the MuleClient to request the other file, Configure the file inbound endpoint to select both XML and PDF files and add a collection-aggregator configured with an expression-message-info-mapping that uses the originalFilename property in a correlation ID expression that extracts the file name sans extension from it. Don't forget to set the MULE_CORRELATION_GROUP_SIZE property to 2 before the aggregator.

Categories : File

Merging files that were amended by two developers
Patterns Version control systems don't assume any specific patterns. You can use them to implement different workflows and it is up to your developers to use best practice. However, branching and merging could be considered fundamental concepts and used by most teams in their workflows. Branching in Subversion is not a very natural operation compared to e.g. Git. Basically it's just a copy of another directory (most likely /trunk). So you could say that Subversion doesn't even assume that you use branching at all. There is not even a svn command dedicated to branching. Merges and auto-merge Two revisions of a single class can be merged. For Subversion they are nothing more than text files. It won't recognize any substructures like classes. The merge algorithm will most likely be able

Categories : Svn

Merging two .csv files python-pandas
Seems you didn't strip the comma symbol in the second csv, you might try to use converters to convert them: In [81]: converters = { 'NAME': lambda x:x[:-1], 'Sdev_I1': lambda x: float(x[:-1]), 'Sdev_I2': lambda x: float(x[:-1]) } In [82]: pd.read_csv('NEW.csv',sep=r's+', converters=converters) Out[82]: NAME Sdev_I1 Sdev_I2 0 Mon-000002 0.023 0.028 1 Mon-000003 0.016 0.016

Categories : Python

merging many DBF (csv) files into one, appending along column
Here is my attempt of inputs and selecting columns desired. import struct, datetime, decimal, itertools import os import csv location = os.listdir("C:UsersjcmDesktopRO") ROfiles = [] Nameoutput = "YouDidntNameMe" Nameoutput = (raw_input("Name output file:")) daytime = (raw_input("Do you want Date/Time Fields? yes or no: ")) num_lists = int(raw_input("How many Data Fields do you want? 1-6:")) if num_lists >= 0: xone = 0 xone = int(raw_input("which Row do you want for Fieldone?")) if num_lists >= 2: xtwo = 0 xtwo = int(raw_input("which Row do you want for Fieldtwo?")) if num_lists >= 3: xthree = 0 xthree = int(raw_input("which Row do you want for Fieldthree?")) if num_lists >=

Categories : Python

Is merging multiple XML files into one more efficient?
To be honest, this falls into the category of problem where readability would be more important than performance. The performance difference between reading 6-7 files or just 1 would be barely anything, definitely nothing noticeable to the user. I'd go with whichever makes your code cleanest as the readability will be worth more in the long run than saving 1 nanosecond of performance if it means losing hours of dev when you revisit it an it's just a mess of xml.

Categories : Android

pypdf Merging multiple pdf files into one pdf
It maybe just what it says, you are opening to many files. You may explicitly use f=file(filename) ... f.close() in the loop, or use the with statement. So that each opened file is properly closed.

Categories : Python

Merging Google Script gs files
There is no reason that the script would stop running if all the code from separate .gs files was faithful copied to a single .gs file. (Although there is no good reason to do this. In fact, it's a good practice to separate code as Romain did in this example.) Did you know? When a script containing multiple 'files' is run, the entire script is 'loaded' and run. To the machine, the existence of multiple gs files is moot - they are simply a convenience for the author. All functions and global variables in all files are available to code in every individual file. All statements outside the scope of functions get executed. (So if you have something like var sheet = SpreadsheetService.getActiveSheet() at the top of every gs file, it will execute multiple times - you just need one.) Your optio

Categories : Google Apps Script

Merging two WAVE files on Android (concatenate)
Try with this code for concatenating the wav files: public class ConcateSongActivity extends Activity { Button mbutt; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mbutt = (Button)findViewById(R.id.button_clickme); mbutt.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { try { FileInputStream fis1 = new FileInputStream("/sdcard/MJdangerous.wav"); FileInputStream fis2 = new FileInputStream("/sdcard/MJBad.wav"); SequenceInputStream sis = new SequenceInputStream(fis1,fis2); FileOut

Categories : Java

Merging directories and joining inner files with bash
You didn't say how you want the files merged, or in what order. I will guess "concatenated, with directory1 appearing before diretory2, and directory2 before directory3"? The following script shows a straightforward way to do this, without relying on fancy substitutions: cd directories mkdir mergeddata for I in directory1 directory2 directory3 ; do # replace with your actual directory list for F in "$I"/* ; do B=$(basename "$F") cat "$F" >> "mergeddata/$B" done done Edit: I added some quotes, in case any of your filenames end up with space characters or other inconvenient white space.

Categories : Linux

Merging two files and handling duplicate entries
It is very likely that you are trying to process an empty line. To ignore empty lines: if (lines[i].Trim() == string.Empty) continue; string[] split = lines[i].Split('|'); if (split.Length != 2) throw new InvalidOperationException("invalid file"); string title = split[0]; string times = split[1]; To ignore invalid lines: string[] split = lines[i].Split('|'); if (split.Length != 2) continue; string title = split[0]; string times = split[1];

Categories : C#

How to process all data from multiple XML files after merging using XSL
You could gather all the Result elements from across the three documents using something like <xsl:variable name="allResults" select="(/ | document('file2.xml') | document('file3.xml'))//Result" /> and then apply predicates to this to count the elements you're interested in, for example <xsl:value-of select=" count($allResults[@testName = 'TestOne'][@outcome = 'Failed'])" /> Instead of a fixed set of file names, if you have a main index.xml that lists all the files you want to combine, for example: <list> <entry name="File1.xml" /> <entry name="File2.xml" /> <entry name="File3.xml" /> </list> then you can use this index as the main input to your stylesheet and the allResults variable becomes: <xsl:variable name="allResu

Categories : Xml

merging xml files using Element Tree in Python
A way I've done something similar in the past is to create an xml document then append the values your looking for. I don't believe there is a way to "merge" them xml = ET.fromstring("<book></book>") document = ET.parse(tempFile) childNodeList = document.findall(xpathQuery) for node in childNodeList: xml.append(node)

Categories : Python

Java: Generic code for merging any 2 XML files
If you have the original XML delivered to Client, run diff against it and save the diff file. Once your factory has generated XML with your fix, apply the diff. I have used Oracle XMLDiff for this kind of stuff when our docs were stored in 11G XMLDB. This should be usable even when the Docs are outside DB, I think. http://docs.oracle.com/cd/B13789_01/appdev.101/b12024/oracle/xml/differ/XMLDiff.html

Categories : Java

Will merging a Git branch with deletions also delete files in master?
You cannot delete files from your branch and not have those deletions also reflected in the master branch when your feature branch is merged into it. Also, in the future, you could always just do the merge locally and see the result. If you don't like it, you could always undo the merge locally and reset master to where it was before by using one of the following: $ git reset --hard head~ $ git reset --hard head^ $ git reset --hard head@{1} $ git reset --hard master@{1} $ git reset --hard <sha of previous commit of master> The first 4 commands are shorthand (in this case) for the last one.

Categories : GIT

Visual Studio 2012 Git, How can I review all the files before merging them?
I use the Git Extensions VS add-on, and it allows that easily. I tried the MS plugin, didn't care for it, and went right back to Git Extensions.

Categories : GIT

Python: appending/merging multiple csv files respecting headers and write to csv
You keep re-opening the file and overwriting it. Open outfile once, before your loops start. For the first file you read, write the header and the rows. For rest of the files, just write the rows. Something like with open(outfile, 'w') as f_out: dict_writer = None for f in files: with open(f, 'r') as f_in: dict_reader = csv.DictReader(f_in) if not dict_writer: dict_writer = csv.DictWriter(f_out, lineterminator=' ', fieldnames=dict_reader.fieldnames) dict_writer.writeheader() for row in dict_reader: if row['Campaign'] in campaign_names: dict_writer.writerow(row)

Categories : Python

Dataset Tables Merging in single dataset with result set
Could you not use the DataTable.Merge method? Start with a clone of the first table and then merge in the data from the other tables? The Merge method has an option, MissingSchemaAction, that lets you specify that new columns should be added to the resulting table so it should do what you are after.

Categories : Asp Net

Merging an Old MySQL dbase with a new dbase> There are some new tables in the new one..?
I would initially back up both the old and new databases using mysqldump or by exporting the databases via phpmyadmin. After that you can then import the old database dump into the new database, which should leave the existing "new" tables and add the tables from your old database. Remember, if anything goes wrong you'll always have your backups handy! P.S. The only time your tables "might" interfere is when you have two tables with the same name but different structures, so be careful with that!

Categories : Mysql

I have the following XML file. I want to create tables dynamically based on testcategory name(in ths case 3 tables) using XSLT
Since the number of rows might vary for each section, one way to account for this problem is to divide up the work according to the hierarchy of the XML document. The Device Details table and Test Summary table should appear side-by-side below the Test Category tables. <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes" version="4.0" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd"/> <xsl:variable name="header_style"> <xsl:text>font-size: 14pt; font-weight: bold; margin-bottom: 1em; width: 40%;</xsl:text> </xsl:variable> <xsl:variable

Categories : Xslt

Using .Sas7bdat file and merging in R
There are two compact methods for passing multiple lists to merge: do.call and Reduce. My attempts with the do.call method failed here (I think) because the third data.frame was being matched to the 'by' argument. Instead, try: newds <-Reduce( function(x,y) merge(x,y, by="id", all=TRUE), list(ds1,ds2,ds3) ) If you do not provide the structure of the dataframes, it's not possible to give further coding advice about how to "compute mean and Standard deviation".

Categories : R

Merging and obfuscating same jar file?
I am still using zOneJar but I switched to JShrink. JShrink is working like a charm, and I am very happy to be able to merge and obfuscate my code now. http://www.e-t.com/jshrink.html No additional settings - just obfuscate the merged jar. Greetings, Dominik

Categories : Java

R Using index of rows for merging file
You can create an appropriate data.frame object out of res: res.df <- data.frame(names=names(res), res=res) Then use this as one of the inputs to merge.

Categories : R



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.