w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Delete Specific Rows in Matlab
fairly large 2x2 matrix makes little or no sense. This is part from MATLAB documentation You can delete rows and columns from a matrix by assigning the empty array [] to those rows or columns. Start with A = magic(4) A = 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1 Then, delete the second column of A using A(:, 2) = [] This changes matrix A to A = 16 3 13 5 10 8 9 6 12 4 15 1 Also you can delete multiple rows/columns at once: A([1 3],:)=[] A = 5 10 8 4 15 1

Categories : Matlab

matlab how to delete rows using logical index
You do not need a loop in this logical indexing task: ismember(A,B) ans = 1 0 1 0 0 0 0 0 All you need is to keep those rows with at least one match with any(...,2): idx = any(ismember(A,B),2) idx = 1 1 0 0 The result: A(idx,:) ans = 4567 345 45 6787 The error is caused by the fact that your loop runs from 1:n but you are removing rows from the matrix making it effectively shorter than n.

Categories : Matlab

Delete multiple rows by sql statement "delete from tableName" whereas TRIGGER "After Delete" had applied on that
Either set @roid=(select ReachOutID from deleted(nolock) where deleted.NotificaionType='reachoutlike') Or set CACHE_Reachout.LIKEcount= (select [dbo].[getReachout_Notification_Count](@roid,'like') ) where CACHE_Reachout.ReachOutID=@roid is returning more than 1 row of data. Raj

Categories : Sql Server

SQL Delete Request spend significant time in "Index Delete" even if it affects 0 rows
I've found joins to be much more performant that subqueries. Try this delete t from Entity t inner join Entity tt ON tt.Id=t.Id where t.Revision <= x and tt.Revision > t.Revision Also, ensure you have an index on Id and Revision.

Categories : SQL

How can I insert new rows and delete missing rows from a table given a collection of values?
Okay, so your collection is in a C# list. That makes this easier. This isn't the most efficient way to do it since it involves a lot of queries, and it would work better using a Dictionary, but it's a solution if you aren't pressed for time and don't want to use string concatenation to make a complicated query. using (SqlConnection connection = new SqlConnection(.....)) { connection.Open; using (SqlCommand command = new SqlCommand("SELECT ID, Value FROM Table")) { using (SqlDataReader reader = SqlCommand.ExecuteReader()) { while (reader.Read()) { if (THELIST.Contains(reader["Value"].ToString()) { THELIST.Remove(reader["Value"].ToString()); } else {

Categories : SQL

Delete first X rows of MySQL table once the number of rows is greater than N
I don't think that's the right way of getting the number of rows. You need to change your statement to have a count(*) and then use MySQLs cursor.fetchone() to get a tuple of the results, where the first position (kinda like wordcount = cursor.fetchone()[0]) will have the correct row count. Your delete statement looks right, maybe you have explicit transactions? in which case you'd have to call commit() on your db object after the delete.

Categories : Python

how to delete first rows if i have pairs of almost identical rows
Inside the subquery, both t2.year and year refer to the column of the t2 table. You must use SULP.year to refer to the outer table: DELETE FROM "SULP" WHERE EXISTS (SELECT 1 FROM "SULP" AS t2 WHERE t2.year = SULP.year AND t2.month = SULP.month AND t2.day = SULP.day AND t2.hour = SULP.hour AND t2.min = SULP.min AND t2.ro < SULP.ro)

Categories : Database

Delete rows from A matching rows in B in SAS
Try this: proc sql; delete from TableA as a where a.v1 = (select b.v1 from TableB as b where a.primaryKey = b.foreignKeyForTableA) and so on for the other values. However, since you may recieve duplicates (ie more than one result) from TableB you might want to try out "select distinct" or "select Top 1" to only get one result.

Categories : SQL

How to delete the axes coordinate in Matlab GUI?
A quick way to turn off the axis is, well, axis off: Example figure; plot([-10:10],randn(21,1)); xlabel('x'); ylabel('y'); Now turn axis off: axis off

Categories : Matlab

Why does MATLAB delete breakpoints in my classdef?
If the class is only on your path because it's in the current directory, then changing the current directory while the code is running may have unexpected results, including clearing breakpoints. Use either the Set Path dialog or the addpath function to add the code's directory to your MATLAB path. This way it can be accessed by MATLAB even if you change the current directory, which should resolve your debugging issues.

Categories : Matlab

how to delete variables in matlab command window?
1) If you have redefined function clear (e.g. by a variable or function), you can use the builtin function to execute built-in clear function. I.e. you can use builtin('clear','all') to clear all variables, respectively builtin('clear','clear') to redefine clear to the built-in clear function and then use it normally clear all 2) If this was not the solution of your problem, could you show us the output of the following code? a = 10; str = 'a'; builtin('clear','all') builtin('who')

Categories : Matlab

Delete elements within cells of array MATLAB
I'm not near a MATLAB pc at the moment, but try: for i=1:11 inter2{i}(1,newinter{i})=[]; end Note that if you're trying to remove the contents of the cell rather than the cell itself, you've got it backwards. {} accesses the contents of the cell, while () returns the cell itself, so you should use {} if you want to keep the cell intact. See this link for an example case.

Categories : Arrays

Delete rows from CSV
Here's a simple solution based on your 5 commas critteria List<String> lines = new List<string>(); string line; System.IO.StreamReader file = new System.IO.StreamReader("c:\test.txt"); while ((line = file.ReadLine()) != null) { lines.Add(line); } lines.RemoveAll(l => l.Contains(",,,,,")); Then you can write it back out or whatever you'd like Writing out : using (System.IO.StreamWriter outfile = new System.IO.StreamWriter(outputPath)) { outfile.Write(String.Join(System.Environment.NewLine, lines.ToArray())); }

Categories : C#

How to delete the border of the edge for character recognition in matlab?
First, I am not sure if your algorithm is really optimized. It seems to be elaborate, but not fitting to your problem. I would simply try a binarization (not using the "logical" command) and then play around with imerode and bwareaopen to get rid of the small stuff around the characters. This should be simpler than your code ...

Categories : Image

Deleted rows with a specified string (MatLab)
You are using strcmp(), which compares the equality of two strings. That is not what you are after; you want to check whether some string is a substring of another string. You can use strfind or findstr or regexp or regexprep for that purpose. ALso, you are not closing your text file. This can lead to all sorts of problems. Make it a habit to always write fid = fopen(...); fclose(fid); as if it is one command, and then continue coding in between. A small example: fid = fopen('text.txt'); tttt = textscan(fid, '%s %s','delimiter',' '); tttt{2}(~cellfun('isempty', strfind(tttt{2}, 'omit'))) = []; fclose(fid); EDIT: based on your comments, I think you want to do this: fid = fopen('text.txt'); % Modified importcommand tttt = textscan(fid, '%s%s',... 'delimiter',' ',....

Categories : Matlab

conditional duplication of rows in matlab
The simplest way would be this: ids = unique(A(:,1)); B = []; for ii = 1:numel(ids) B = [B; repmat( A(A(:,1)==ids(ii),:), w(ii),1)]; %#ok end Note that this is not very efficient, but that will only be a problem if you have a very large data set that you need to replicate like this very often. For a couple of one-off shots, this will amply suffice.

Categories : Matlab

Not able to delete rows using HandsOnTable
So i am guessing you want to delete an empty last row ? Make sure you have not set minSpareRows to a value more than 0(default) . If the minSpareRows is more than zero u cannot delete the extra row using alter('remove_row'). i used this data to simulate the empty last row : var myData = [ ["", "Kia", "Nissan", "Toyota", "Honda"], ["2008", 10, 11, 12, 13], ["2009", 20, 11, 14, 13], ["2010", 30, 15, 12, 13], ["",,,] ]; Checkout the example .When u click on del link it deletes the empty last row . Hope this helps you Working Example

Categories : Jquery

Macro to delete Rows containing #N/A
This is a partial solution. The following macro will remove all rows in which the only value is in column A: Sub RowKiller() Dim N As Long, NN As Long Dim r As Range NN = Cells(Rows.Count, "A").End(xlUp).Row Dim wf As WorksheetFunction Set wf = Application.WorksheetFunction For N = NN To 1 Step -1 Set r = Cells(N, "A") If wf.CountA(r) = 1 And wf.CountA(r.EntireRow) = 1 Then r.EntireRow.Delete End If Next N End Sub

Categories : Excel

Delete partial rows in VBA
This should do you: Sub RemoveX() Dim iRows As Integer Dim x As Integer Application.ScreenUpdating = False iRows = Range("A1").CurrentRegion.Rows.Count For x = iRows To 1 Step -1 If Application.WorksheetFunction.IsNA(Cells(x, 2)) Then Application.Intersect(Cells(x, 2).EntireRow, _ Range("A1:D1").EntireColumn).Delete ElseIf Cells(x, 2).Value = "-" Then Application.Intersect(Cells(x, 2).EntireRow, _ Range("A1:D1").EntireColumn).Delete End If Next x Application.ScreenUpdating = True End Sub CurrentRegion is the region obtained if you click into A1 and press Ctrl-A. If could be tidied up a little (using Range references and not using EntireRow or -Column) but it works.

Categories : Excel

Can't delete rows in mysql
These things? foreach ($_POST["borrar_usuario"] as $valor){ $del_user = $valor; $q_borrar = "delete from usuarios where id_user in ('$del_user')"; mysqli_query($con, $q_borrar); echo "usuario borrado"; header('refresh: 3; url= exito.php'); }

Categories : PHP

Delete all rows coresponding to given ID
set.seed(42) DF <- data.frame(a = sample(c("a", "b", "c"), 10, T), b = sample(1:10, 10, T)) # a b # 1 c 5 # 2 c 8 # 3 a 10 # 4 c 3 # 5 b 5 # 6 b 10 # 7 c 10 # 8 a 2 # 9 b 5 # 10 c 6 library(plyr) res <- ddply(DF, .(a), transform, test = any(b %in% c(2, 3))) res[!res$test, 1:2] # a b # 3 b 5 # 4 b 10 # 5 b 5

Categories : R

Delete rows in Gridview
Remove the rows but don't re-bind the gridview. Use GridView.DeleteRow method to remove the rows you filtered in the arraylist del. When you call GridView1.DataBind(); without setting a DataSource you will be binding nothing. Similar How to delete row from gridview?

Categories : C#

R - How to delete rows by a value, when NAs are present
You'll need a combination of the function is.na and the OR (|) operator: data1[!data1$sp | is.na(data1$sp),] Using subset notation: subset(data1, !sp | is.na(sp))

Categories : R

Using Matlab, how can I group rows by year into a structure?
It's not loop free, but close enough I guess. for ii = 1:length(yrsStr)-1 struct(ii).data = X(X(:,1) >= yrsStr(ii) & X(:,1) < yrsStr(ii+1),:); end struct(length(yrsStr)).data = X(X(:,1) >= yrsStr(length(yrsStr)),:); I can't think of a faster way of doing the last line. (Except using if, or adding a term in the end of yrsStr with a big number, and make the loop go an extra step. The last one would be: yrsStr(end+1) = inf; for ii = 1:length(yrsStr)-1 struct(ii).data = X(X(:,1) >= yrsStr(ii) & X(:,1) < yrsStr(ii+1),:); end Good luck!

Categories : Matlab

how to get the length (count of rows) of this matlab matrix?
Just use the size function size(ans, 1) But if you're asking this, I suggest you work through some basic Matlab tutorials before you continue...

Categories : Matlab

MATLAB - Counting the # of rows that are only numbered with multiples of 5
you can convert day-hour-min into minutes. Suppose your data is stored in an n-by-3 matrix called data (how original). Then >> minutes = data * [24*60; 60; 1]; % counting minutes from the begining Now you have to define the bins' edges (the intervals for summation): >> edges = min(minutes) : 5 : max(minutes); % you might want to round the lower and upper limits to align with a 5 minute interval. Use histc to count how many drops in each bin >> drops = histc(minutes, edges);

Categories : Matlab

How to crop rows and columns of pixels out in MATLAB
U can use imcrop for this if you have image processing toolbox or you can make new image as follows: I2 = I(21:end-5, 6:end-5) For 3 dimensions, you can use: I2 = I(21:end-5,6:end-5,:) For example as per your comment: I = rand(153,1510,3); size(I); % 153 1510 3 I2 = I(21:end-5,6:end-5,:); size(I2); % 128 1500 3

Categories : Matlab

Delete rows that contains null value from dataTable
public static void RemoveNullColumnFromDataTable(DataTable dt) { for (int i = dt.Rows.Count - 1; i >= 0; i--) { if (dt.Rows[i][1] == DBNull.Value) dt.Rows[i].Delete(); } dt.AcceptChanges(); }

Categories : C#

Rows won't delete when using left join
Here is the same thing that you faced and the answer for that. Go to this link and see how to be done link for the answer

Categories : Mysql

delete duplicate rows from large dB
I really wouldn't use NOT IN. I would ensure that there is an index on myText, id and then try this... DELETE FROM yourTable WHERE id > 40000 AND id <= 50000 AND EXISTS (SELECT * FROM yourTable AS lookup WHERE lookup.myText = yourTable.myText AND lookup.id > yourTable.id ) This way you only check the myText values that you are potentially deleting. Where as your sub-query will return ids for myTexts that don't even appear in the range you are checking.

Categories : Mysql

Delete rows from a dataframe but keep rownames
I think that both of these work: d1 <- head(sp500ret, n=1000L) rownames(d1) d2 <- subset(sp500ret, c(1:length(SP500RET)) < 1001) rownames(d2) # Solution from @Penguin_Knight d3 <- subset(sp500ret, row(sp500ret) < 1001) rownames(d3)

Categories : R

Delete all except the last x number of rows in database
Sure, just do it as you suggested: delete_all_but_oldest_30.rake: task :delete_all_but_oldest_30 => :environment do query = MyModel.order("created_at desc") query.limit(query.count - 30).destroy_all end You should customize this as you see fit-- you just need to decide what 'last' means: oldest, highest ID, lowest ID, etc. Just use the reverse of whatever order you'd like so that the last 30 results are those that you'd like to keep. So to keep the lowest IDs, order by "id desc". Note: This technically doesn't guarantee that exactly 30 records are left because it is non-transactional. When more records are added asynchronously while this rake task is running, the result is not deterministic. Depending on your application, this may or may not be a problem. If you're just delet

Categories : Ruby On Rails

Delete rows in sybase with joins
Try this way: DELETE "sac"."vendor_item_cost" FROM "sac"."vendor_item_cost" as c,(SELECT c1.Vendor_id, c1.Item_Number, MAX(c1.Last_edit_timestamp) as [Date] FROM "sac"."vendor_item_cost" c1 JOIN "sac"."vendor_item_cost" c2 ON c1.Vendor_id = c2.Vendor_id AND c1.Item_Number = c2.Item_Number GROUP BY c1.Vendor_id, c1.Item_Number ) q WHERE c.Vendor_id = q.vendor_id AND c.Item_Number = q.Item_Number AND c.Last_edit_timestamp <> q.[Date]

Categories : SQL

Delete all duplicate rows Excel vba
There's a RemoveDuplicates method that you could use: Sub DeleteRows() With ActiveSheet Set Rng = Range("A1", Range("B1").End(xlDown)) Rng.RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes End With End Sub

Categories : Excel

Delete large number of rows
As You really want to delete high percentage, so you may consider this approach SELECT col1, col2, ... INTO #SomeHoldingtable FROM MyTable WHERE ..condition.. TRUNCATE TABLE MyTable INSERT MyTable (col1, col2, ...) SELECT col1, col2, ... FROM #SomeHoldingtable

Categories : Sql Server

Delete rows from 4 tables based on one?
I'm agree with zerkms - you could use cascade foreign keys. But it could be written as SQL queries too, but if you have foreign keys, you have to do it in correct order, something like: delete from posts_tags where tag_id in (select id from tags where user_id = <your user id>) or post_id in (select post_id from posts where user_id = <your user id>) delete from tags where user_id = <your user id> delete from posts where user_id = <your user id> delete from users where user_id = <your user id>

Categories : Mysql

Delete duplicate rows in mysql
You forgot to mention count(*)>1 DELETE FROM location where country in ( SELECT * FROM table_name GROUP BY country, state, city having COUNT(*)>1); Just for your information. You can also use ALTER IGNORE TABLE to delete the duplicates. Something like this:- ALTER IGNORE TABLE location ADD UNIQUE INDEX (COLUMN1, COLUMN2)

Categories : Mysql

Procedure to delete table rows
DELETE doesn't takes an expression that results in a table id; it takes a table id literal. As such, you can't use replaceable parameters. You need to construct the table id literal, which $dbh->quote_identifier can do. my $sql = 'DELETE '.$dbh->quote_identifier($dbID); $dbh->do($sql); You are using a module that wraps DBI in a very poor way1. I have no way of knowing if it'll give access to the database handle or to the handle's quote_identifier method, but at least now you know what to look for. Notes: There are three ways to wrap DBI that make sense: To add functions or override some minor aspect of existing functions. For example, DBI database statements don't have the selectrow_* methods founds on database handles. Adding these without restricting access to the res

Categories : Oracle

Handsontable delete multiple rows
your "selection" variable is not visible within the scope of the onClick handler. Try moving "var selection = ..." into the handler function. Something like... $('.deletebutton').on('click', function () { var selection = $edit.handsontable('getSelected'); $edit.handsontable('alter', 'remove_row', selection[0], selection[2]); });

Categories : Jquery

Delete rows from table with no primary key, SQL
In most SQL dialects you can do: delete from likes where not exists (select 1 from likes l2 where l2.id1 = likes.id2 and l2.id2 = likes.id1) and exists (select 1 from friends f where f.id1 = likes.id1 and f.id2 = likes.id2); This is pretty much a direct translation of your two conditions.

Categories : SQL



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