command line interface

 

https://www.macworld.com/article/222596/command-line-deleting-files-folders-mac-terminal.html

 

Master the macOS command line: How to delete files and folders using Terminal

The command line is not only powerful, it can also be dangerous. Learn how to use commands for deleting files and folders correctly to make sure your time with Terminal is a productivity godsend instead of a complete disaster.

www.macworld.com

rm order can not retrive deleted file

rm

rm -R folderName : can drop the full path into the commander from finder

rm -i : ask one more

 

/Library/Preferences/Parellels

/Users/youngkim/Library/Preferences

 

defaults write com.apple.finder AppleShowAllFiles -bool true

defaults write com.apple.finder AppleShowAllFiles -bool false

 

{% regroup column_list_bottom_left by 국내해외 as data0 %}
    {% for eachDom in data0 %}
        {% regroup eachDom.list by 본부 as data1 %}
            {% for eachBonbu in data1 %}
                {% regroup eachBonbu.list by 현장 as data2 %}
                    {% for eachSite in data2 %}
                        <!-- 각 줄별로-->
                        {% for rowData in eachSite.list %}
                            <tr>
                                {% if forloop.first %}
                                    {% if forloop.parentloop.first %}
                                        {% if forloop.parentloop.parentloop.first %}
                                            <td class="data" rowspan="{{eachDom.list|length}}"><div class="align-center ellipsis" style="width:100px;">{{eachDom.grouper}}</div></td>
                                        {% endif %}
                                        <td class="data" rowspan="{{eachBonbu.list|length}}"><div class="align-center ellipsis" style="width:100px;">{{eachBonbu.grouper}}</div></td>
                                    {% endif %}
                                <td class="data" rowspan="{{eachSite.list|length}}"><div class="align-center ellipsis" style="width:250px;">{{eachSite.grouper}}</div></td>
                                {% endif %}

                                <td class="data"><div class="align-center ellipsis" style="width:200px;">{{rowData.업체}}</div></td>
                                <td class="data"><div class="align-center ellipsis" style="width:100px;">{{rowData.입력일수}}</div></td>
                            </tr>
                        {% endfor %}
                    {% endfor %}
            {% endfor %}
    {% endfor %}

템플릿 코드만으로 HTML Table에서 하기와 같은 표를 만들 수 있음

 

 

'코딩' 카테고리의 다른 글

JAVA - Stream 예제  (0) 2022.10.06
Ajax, django 협업 코드  (0) 2022.08.02
Pandas, 데이터 컨트롤링 예시 코드  (0) 2022.08.02
pywin32 - win32com.client / chart control  (0) 2022.08.02
데이터프레임, 파이썬 공부하기  (0) 2021.10.10
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;


class Bonbu {
    String name;
    int numberOfSite;
    int revenue;

    public Bonbu(String name, int numberOfSite, int revenue) {
        this.name = name;
        this.numberOfSite = numberOfSite;
        this.revenue = revenue;
    }

    String getName() {
        return this.name;
    }

    int getNumberOfSite() {
        return this.numberOfSite;
    }

    int getRevenue() {
        return this.revenue;
    }

    @Override
    public String toString() {
        return name + " - number of site : "+ numberOfSite +" - revenue: "+revenue;
    }
}

public class Sample {
    public static void main(String[] args) {
        List<Bonbu> bonbus = new ArrayList<>(Arrays.asList(
                new Bonbu("tomo", 100, 200),
                new Bonbu("kucu", 300, 700),
                new Bonbu("plnt", 50, 1000),
                new Bonbu("zoki", 60, 1000)
        ));

        List<Bonbu> result = bonbus.stream()
                .filter(x->x.revenue>300)
                .sorted(Comparator
                        .comparing(Bonbu::getRevenue)
                        .thenComparing(Bonbu::getNumberOfSite).reversed()
                )
                .collect(Collectors.toList());

        result.forEach(System.out::println);
    }
}

JAVA에서도 Python의 판다스처럼 사용할 수 있는 스타일이 있군요.

Dart에도 이와 유사한(모사한) 방식이 있습니다. 

 

 

<script>
    $ (document).on("click", "#del_subcon", function() {
        param = $(this).val().split("+")
        subcon_name_key = param[0]
        subcon_name_simular = param[1]
        sendData = {
            'subcon_name_key': param[0],
            'subcon_name_simular': param[1],
        }
        request_url = {% url 'MDCheckerSubconAjax' %}
        $.ajax({
            url: request_url,
            type: 'POST',
            headers: {'X-CSRFTOKEN': '{{ csrf_token }}'},
            data: JSON.stringify(sendData),
            success: function(getData) {
                $(".subcon_table").remove()
                subcon_list = getData.subcon_list
                console.log(subcon_list)
                $.each(subcon_list, function(index, item){
                    var tr_temp = $(`<tr class="subcon_table"><td class="data" style="text-align:left">${item.업체명key}</td><td class="data" style="text-align:left">${item.업체명}</td><td class="data" style="text-align:center"><button id="del_subcon" type="button" value="${item.업체명key}+${item.업체명}">삭제</button></td></tr>`)
                    $("#subcon_table_all").append(tr_temp)
                })
            },
            error: function(e) {
                console.log(e)
            }
        })
    })
</script>

판다스의 멋진 기능중의 하나

 

stack

unstack

groupby

 

def excel_accumulate_page(self):
    dc = self.dc
    df = dc.request_accumulate_data_by_site(self.siteCode, self.month)
    # columns = ['ㄴㄴ', 'ㄴㄴ', 'ㄴㄴ', 'ㄴㄴㄴㄴ']
    df = df.astype({'ㄴㄴ': float, 'ㄴㄴ': float})

    df['구분'] = df['업체명'].apply(lambda x: 'ㄴ' if 'ㄴ' in x else 'ㄴ')
    if 'ㄴ' not in df['ㄴ'].unique():
        df_temp = pd.DataFrame([['ㄴ', '', self.month, 0, 0]], columns=['ㄴ', 'ㄴ', 'ㄴ', 'ㄴ', 'ㄴ'])
        df = pd.concat([df, df_temp])
    if 'ㄴ' not in df['ㄴ'].unique():
        df_temp = pd.DataFrame([['ㄴ', 'ㄴ(주)', self.month, 0, 0]], columns=['ㄴ', 'ㄴ', 'ㄴ', 'ㄴ', 'ㄴ'])
        df = pd.concat([df, df_temp])

    # 자료가 없는 달의 컬럼 생성
    M0 = self.month
    M1 = (datetime.strptime(M0, '%Y-%m') - relativedelta(months=1)).strftime('%Y-%m')
    M2 = (datetime.strptime(M0, '%Y-%m') - relativedelta(months=2)).strftime('%Y-%m')
    M3 = (datetime.strptime(M0, '%Y-%m') - relativedelta(months=3)).strftime('%Y-%m')

    for m in [M0, M1, M2, M3]:
        if m not in df['분석월'].unique():
            df_temp = df.drop_duplicates('업체명').copy()
            df_temp.loc[:, '분석월'] = m
            df_temp.loc[:, 'ㄴ'] = 0
            df_temp.loc[:, 'ㄴ'] = 0
            df = pd.concat([df, df_temp])

    df = df[['ㄴ', 'ㄴ', 'ㄴ', 'ㄴ', 'ㄴ']]
    df = df.sort_values(['ㄴ', 'ㄴ', 'ㄴ'], ascending=[True, True, True])
    df = df.set_index(['ㄴ', 'ㄴ', 'ㄴ'])
    df = df.stack(-1)
    df = df.unstack(-2)
    df = df.fillna(0)

    temp = [d for k, d in df.groupby(level=0)]
    df_hd, df_subcon = temp

    # ㄴ 누계
    df_hd_cumsum = df_hd.sum(level=-1).cumsum(axis=1)
    df_hd_cumsum = df_hd_cumsum.rename({'ㄴ': ('ㄴ', '누 계', 'ㄴ'), 'ㄴ': ('ㄴ', '누 계', 'ㄴ')})
    df_hd = pd.concat([df_hd, df_hd_cumsum])

    # ㄴ 소계 및 누계
    df_subcon_sum = df_subcon.sum(level=-1)
    df_subcon_sum = df_subcon_sum.rename({'ㄴ': ('ㄴ', '소 계', 'ㄴ'), 'ㄴ': ('ㄴ', '소 계', 'ㄴ')})
    df_subcon_cumsum = df_subcon.sum(level=-1).cumsum(axis=1)
    df_subcon_cumsum = df_subcon_cumsum.rename({'ㄴ': ('ㄴ', '누 계', 'ㄴ'), 'ㄴ': ('ㄴ', '누 계', 'ㄴ')})
    df_subcon = pd.concat([df_subcon, df_subcon_sum])
    df_subcon = pd.concat([df_subcon, df_subcon_cumsum])

    # 합치기
    df_result = pd.concat([df_hd, df_subcon])

    # 전체 합계 및 누계
    df_sum = df.sum(level=-1)
    df_sum = df_sum.rename({'ㄴ': ('ㄴ', '', 'ㄴ'), 'ㄴ': ('ㄴ', '', 'ㄴ')})
    df_cumsum = df.sum(level=-1).cumsum(axis=1)
    df_cumsum = df_cumsum.rename({'ㄴ': ('ㄴ', '', 'ㄴ'), 'ㄴ': ('ㄴ', '', 'ㄴ')})
    df_result = pd.concat([df_result, df_sum])
    df_result = pd.concat([df_result, df_cumsum])

    # 비고 삽입
    df_result.loc[:, '비 고'] = ''
    return df_result

엑셀 자동화 중 차트를 그리기 위한 메소드입니다. 

도움이 되실 분이 계실까 하여 올려봅니다.

 

import psutil
import win32com.client

for proc in psutil.process_iter():
    if proc.name() == "EXCEL.EXE":
        proc.kill()

excel = win32com.client.dynamic.Dispatch('Excel.Application')
fileName = r"C:\Users\hdec\Desktop\..."
wb = excel.Workbooks.Open(fileName)

excel.Visible = True
excel.DisplayAlerts = False

ws = wb.Sheets(1)

# sheetName = ws.Name
# usedRangeData = ws.UsedRange()

chart = wb.Charts.Add()
chart.HasTitle = True
chart.Name = '차트'

s1 = chart.SeriesCollection(1)
s2 = chart.SeriesCollection(2)
s3 = chart.SeriesCollection(3)
s4 = chart.SeriesCollection(4)
s5 = chart.SeriesCollection(5)
s6 = chart.SeriesCollection(6)
s7 = chart.SeriesCollection(7)
s8 = chart.SeriesCollection(8)
s9 = chart.SeriesCollection(9)
s10 = chart.SeriesCollection(10)
s11 = chart.SeriesCollection(11)

s2.Delete()
s4.Delete()
s5.Delete()
s6.Delete()
s7.Delete()
s9.Delete()
s10.Delete()

s1.Interior.ColorIndex = 5
s8.Interior.ColorIndex = 45

s3.ChartType = 4
s11.ChartType = 4

s3.Border.ColorIndex = 10
s11.Border.ColorIndex = 3

s1.AxisGroup = 1
s8.AxisGroup = 1
s3.AxisGroup = 2
s11.AxisGroup = 2




chart.HasTitle = True
chart.ChartTitle.Text = "■ ㄴㄴㄴ "
chart.ChartTitle.Left = 10

x_axis = chart.Axes(1)
y1_axis = chart.Axes(2, 1)
y2_axis = chart.Axes(2, 2)

# x_axis.HasTitle = True
y1_axis.HasTitle = True
y2_axis.HasTitle = True

# x_axis.AxisTitle.Text = "년월"
y1_axis.AxisTitle.Text = "ㄴㄴㄴ"
y2_axis.AxisTitle.Text = "ㄴㄴㄴㄴ (%)"

y1_axis.TickLabels.NumberFormat = '#,,'
y2_axis.TickLabels.NumberFormat = '0'
y1_axis.MinimumScale = 0

chart.ChartArea.Interior.ColorIndex = 0
chart.PlotArea.Interior.ColorIndex = 34
chart.ChartArea.Border.ColorIndex = 2
chart.PlotArea.Border.ColorIndex = 2
y1_axis.MajorGridLines.Delete()



wb.Save()
wb.Close(False)

+ Recent posts